diff --git a/CodeMaid/UI/ToolWindows/Spade/SpadeView.xaml.cs b/CodeMaid/UI/ToolWindows/Spade/SpadeView.xaml.cs index 4ded1833..f0c38c76 100644 --- a/CodeMaid/UI/ToolWindows/Spade/SpadeView.xaml.cs +++ b/CodeMaid/UI/ToolWindows/Spade/SpadeView.xaml.cs @@ -22,6 +22,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using System.Windows.Interactivity; namespace SteveCadwallader.CodeMaid.UI.ToolWindows.Spade { @@ -430,14 +431,10 @@ private IList GetSelectedTreeViewItemsIncluding(TreeViewItem treeV // If the specified tree view item is not selected, change the current selection to it. if (!selectedTreeViewItems.Contains(treeViewItem)) { - foreach (var selectedTreeViewItem in selectedTreeViewItems) - { - TreeViewMultipleSelectionBehavior.SetIsItemSelected(selectedTreeViewItem, false); - } + var behavior = Interaction.GetBehaviors(treeView).OfType().FirstOrDefault(); + behavior?.SelectSingleItem(treeViewItem); selectedTreeViewItems.Clear(); - - TreeViewMultipleSelectionBehavior.SetIsItemSelected(treeViewItem, true); selectedTreeViewItems.Add(treeViewItem); } diff --git a/CodeMaid/UI/TreeViewMultipleSelectionBehavior.cs b/CodeMaid/UI/TreeViewMultipleSelectionBehavior.cs index 2afbef4a..ace642d3 100644 --- a/CodeMaid/UI/TreeViewMultipleSelectionBehavior.cs +++ b/CodeMaid/UI/TreeViewMultipleSelectionBehavior.cs @@ -140,7 +140,7 @@ protected override void OnDetaching() #endregion Behavior - #region Methods + #region Event Handlers /// /// Called when a TreeViewItem receives a key down event. @@ -224,11 +224,15 @@ private void OnTreeViewItemMouseUp(object sender, MouseButtonEventArgs e) } } + #endregion Event Handlers + + #region Methods + /// /// Selects a range of consecutive items from the specified tree view item to the anchor (if exists). /// /// The triggering tree view item. - private void SelectMultipleItemsContinuously(TreeViewItem treeViewItem) + public void SelectMultipleItemsContinuously(TreeViewItem treeViewItem) { if (AnchorItem != null) { @@ -262,7 +266,7 @@ private void SelectMultipleItemsContinuously(TreeViewItem treeViewItem) /// Selects the specified tree view item, removing any other selections. /// /// The triggering tree view item. - private void SelectSingleItem(TreeViewItem treeViewItem) + public void SelectSingleItem(TreeViewItem treeViewItem) { DeSelectAll(); SetIsItemSelected(treeViewItem, true); @@ -273,7 +277,7 @@ private void SelectSingleItem(TreeViewItem treeViewItem) /// Toggles the selection state of the specified tree view item. /// /// The triggering tree view item. - private void ToggleSingleItem(TreeViewItem treeViewItem) + public void ToggleSingleItem(TreeViewItem treeViewItem) { SetIsItemSelected(treeViewItem, !GetIsItemSelected(treeViewItem));