diff --git a/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml b/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml index aadfc14e03ad..b8513aa97cff 100644 --- a/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml +++ b/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml @@ -219,10 +219,11 @@ Padding="0" HorizontalAlignment="Left" VerticalAlignment="Top" + AutomationProperties.AccessibilityView="Raw" Checked="ItemSelected_Checked" DoubleTapped="SelectionCheckbox_DoubleTapped" - Unchecked="ItemSelected_Unchecked" - Visibility="Collapsed" /> + Opacity="0" + Unchecked="ItemSelected_Unchecked" /> - + @@ -302,10 +303,11 @@ Padding="0" HorizontalAlignment="Left" VerticalAlignment="Top" + AutomationProperties.AccessibilityView="Raw" Checked="ItemSelected_Checked" DoubleTapped="SelectionCheckbox_DoubleTapped" - Unchecked="ItemSelected_Unchecked" - Visibility="Collapsed" /> + Opacity="0" + Unchecked="ItemSelected_Unchecked" /> - + diff --git a/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs b/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs index 13d9ca20dbc2..f07c2263fdaa 100644 --- a/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs +++ b/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs @@ -434,16 +434,18 @@ checkBox.DataContext is ListedItem item && private new void FileList_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { - args.ItemContainer.PointerEntered -= ItemRow_PointerEntered; - args.ItemContainer.PointerExited -= ItemRow_PointerExited; - args.ItemContainer.PointerCanceled -= ItemRow_PointerCanceled; + var selectionCheckbox = args.ItemContainer.FindDescendant("SelectionCheckbox")!; + + selectionCheckbox.PointerEntered -= SelectionCheckbox_PointerEntered; + selectionCheckbox.PointerExited -= SelectionCheckbox_PointerExited; + selectionCheckbox.PointerCanceled -= SelectionCheckbox_PointerCanceled; base.FileList_ContainerContentChanging(sender, args); SetCheckboxSelectionState(args.Item, args.ItemContainer as GridViewItem); - args.ItemContainer.PointerEntered += ItemRow_PointerEntered; - args.ItemContainer.PointerExited += ItemRow_PointerExited; - args.ItemContainer.PointerCanceled += ItemRow_PointerCanceled; + selectionCheckbox.PointerEntered += SelectionCheckbox_PointerEntered; + selectionCheckbox.PointerExited += SelectionCheckbox_PointerExited; + selectionCheckbox.PointerCanceled += SelectionCheckbox_PointerCanceled; } private void SetCheckboxSelectionState(object item, GridViewItem? lviContainer = null) @@ -464,7 +466,7 @@ private void SetCheckboxSelectionState(object item, GridViewItem? lviContainer = checkbox.Unchecked += ItemSelected_Unchecked; } - UpdateCheckboxVisibility(container); + UpdateCheckboxVisibility(container, checkbox?.IsPointerOver ?? false); } } @@ -481,37 +483,35 @@ private void Grid_Loaded(object sender, RoutedEventArgs e) itemContainer.ContextFlyout = ItemContextMenuFlyout; } - private void ItemRow_PointerEntered(object sender, PointerRoutedEventArgs e) + private void SelectionCheckbox_PointerEntered(object sender, PointerRoutedEventArgs e) { - UpdateCheckboxVisibility(sender, true); + UpdateCheckboxVisibility((sender as FrameworkElement)!.FindAscendant()!, true); } - private void ItemRow_PointerExited(object sender, PointerRoutedEventArgs e) + private void SelectionCheckbox_PointerExited(object sender, PointerRoutedEventArgs e) { - UpdateCheckboxVisibility(sender, false); + UpdateCheckboxVisibility((sender as FrameworkElement)!.FindAscendant()!, false); } - private void ItemRow_PointerCanceled(object sender, PointerRoutedEventArgs e) + private void SelectionCheckbox_PointerCanceled(object sender, PointerRoutedEventArgs e) { - UpdateCheckboxVisibility(sender, false); + UpdateCheckboxVisibility((sender as FrameworkElement)!.FindAscendant()!, false); } - private void UpdateCheckboxVisibility(object sender, bool? isPointerOver = null) + private void UpdateCheckboxVisibility(object sender, bool isPointerOver) { if (sender is GridViewItem control && control.FindDescendant() is UserControl userControl) { - // Save pointer over state accordingly - if (isPointerOver.HasValue) - control.SetValue(IsPointerOverProperty, isPointerOver); // Handle visual states // Show checkboxes when items are selected (as long as the setting is enabled) - // Show checkboxes when hovering of the item (regardless of the setting to hide them) + // Show checkboxes when hovering over the checkbox area (regardless of the setting to hide them) if (UserSettingsService.FoldersSettingsService.ShowCheckboxesWhenSelectingItems && control.IsSelected - || control.GetValue(IsPointerOverProperty) is not false) + || isPointerOver) VisualStateManager.GoToState(userControl, "ShowCheckbox", true); else VisualStateManager.GoToState(userControl, "HideCheckbox", true); } } + } }