diff --git a/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs b/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs index 60147ac9aaf4..77e7d6a10cd9 100644 --- a/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs +++ b/src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs @@ -714,7 +714,16 @@ private void SetCheckboxSelectionState(object item, ListViewItem? lviContainer = { var checkbox = container.FindDescendant("SelectionCheckbox") as CheckBox; if (checkbox is not null) + { + // Temporarily disable events to avoid selecting wrong items + checkbox.Checked -= ItemSelected_Checked; + checkbox.Unchecked -= ItemSelected_Unchecked; + checkbox.IsChecked = FileList.SelectedItems.Contains(item); + + checkbox.Checked += ItemSelected_Checked; + checkbox.Unchecked += ItemSelected_Unchecked; + } } } diff --git a/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs b/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs index 92ae3e864a9c..4d9d2b0c4b2f 100644 --- a/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs +++ b/src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs @@ -471,7 +471,16 @@ private void SetCheckboxSelectionState(object item, GridViewItem? lviContainer = { var checkbox = container.FindDescendant("SelectionCheckbox") as CheckBox; if (checkbox is not null) + { + // Temporarily disable events to avoid selecting wrong items + checkbox.Checked -= ItemSelected_Checked; + checkbox.Unchecked -= ItemSelected_Unchecked; + checkbox.IsChecked = FileList.SelectedItems.Contains(item); + + checkbox.Checked += ItemSelected_Checked; + checkbox.Unchecked += ItemSelected_Unchecked; + } } }