Skip to content

Commit

Permalink
Fix focus when switching back to assembly list via keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-englert committed Oct 5, 2024
1 parent d989085 commit 5a1ec2c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ILSpy/AssemblyTree/AssemblyListPane.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:treeNodes="clr-namespace:ICSharpCode.ILSpy.TreeNodes"
xmlns:assemblyTree="clr-namespace:ICSharpCode.ILSpy.AssemblyTree"
xmlns:toms="urn:TomsToolbox"
xmlns:viewModels="clr-namespace:ICSharpCode.ILSpy.ViewModels"
mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance assemblyTree:AssemblyTreeModel}"
AutomationProperties.Name="Assemblies and Classes"
Expand All @@ -15,7 +16,8 @@
AllowDrop="True"
BorderThickness="0" Visibility="Visible"
Root="{Binding Root}"
toms:MultiSelectorExtensions.SelectionBinding="{Binding SelectedItems, Mode=TwoWay}">
toms:MultiSelectorExtensions.SelectionBinding="{Binding SelectedItems, Mode=TwoWay}"
viewModels:Pane.IsActive="{Binding IsActive}">
<treeView:SharpTreeView.ItemContainerStyle>
<Style TargetType="treeView:SharpTreeViewItem">
<Setter Property="Template">
Expand Down
17 changes: 17 additions & 0 deletions ILSpy/AssemblyTree/AssemblyListPane.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
using System.Windows;
using System.Windows.Threading;

using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX.TreeView;

using TomsToolbox.Wpf.Composition.Mef;

namespace ICSharpCode.ILSpy.AssemblyTree
Expand Down Expand Up @@ -59,6 +62,20 @@ protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
});
}
}
else if (e.Property == Pane.IsActiveProperty)
{
if (!true.Equals(e.NewValue))
return;

if (SelectedItem is SharpTreeNode selectedItem)
{
FocusNode(selectedItem);
}
else
{
Focus();
}
}
}
}
}

0 comments on commit 5a1ec2c

Please sign in to comment.