From 8abb59cc03fad9a672232ee5d9a631c4a31f6329 Mon Sep 17 00:00:00 2001 From: hishitetsu <66369541+hishitetsu@users.noreply.github.com> Date: Fri, 10 Feb 2023 23:21:31 +0900 Subject: [PATCH] Avoid selecting wrong items --- .../Views/LayoutModes/DetailsLayoutBrowser.xaml.cs | 9 +++++++++ src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs | 9 +++++++++ 2 files changed, 18 insertions(+) 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; + } } }