Kategorie

This commit is contained in:
Meik
2025-11-11 20:22:10 +01:00
parent 05fb34815a
commit 8cf1c84328
2 changed files with 14 additions and 30 deletions

View File

@@ -11,7 +11,7 @@ using System.Windows.Threading;
namespace FasdDesktopUi.Basics.UserControls
{
public partial class HierarchicalSelectionControl : UserControl, IFocusInvoker
public partial class HierarchicalSelectionControl : UserControl
{
private readonly ObservableCollection<HierarchicalSelectionItem> visibleItems = new ObservableCollection<HierarchicalSelectionItem>();
private readonly Dictionary<string, HierarchicalSelectionItem> itemLookup = new Dictionary<string, HierarchicalSelectionItem>();
@@ -19,8 +19,8 @@ namespace FasdDesktopUi.Basics.UserControls
private string lastSearchText = string.Empty;
public ObservableCollection<HierarchicalSelectionItem> VisibleItems => visibleItems;
public int? ParentIndex { get; set; }
public UIElement ParentElement { get; set; }
public event EventHandler DropDownOpened;
public event EventHandler DropDownClosed;
public HierarchicalSelectionControl()
{
@@ -97,27 +97,13 @@ namespace FasdDesktopUi.Basics.UserControls
{
SearchTextBox.Focus();
SearchTextBox.SelectAll();
EnsureParentPlacement();
cFocusInvoker.InvokeGotFocus(this, e);
DropDownOpened?.Invoke(this, e);
}
private void DropDownPopup_Closed(object sender, EventArgs e)
{
searchDelayTimer.Stop();
cFocusInvoker.InvokeLostFocus(this, e);
}
private void EnsureParentPlacement()
{
if (ParentElement == null || ParentElement != this.Parent)
{
ParentElement = this.Parent as UIElement;
if (this.Parent is Panel panel)
ParentIndex = panel.Children.IndexOf(this);
else
ParentIndex = null;
}
DropDownClosed?.Invoke(this, e);
}
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)