Kategorie
This commit is contained in:
@@ -18,6 +18,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
private readonly Dictionary<string, HierarchicalSelectionItem> itemLookup = new Dictionary<string, HierarchicalSelectionItem>();
|
||||
private readonly DispatcherTimer searchDelayTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(250) };
|
||||
private string lastSearchText = string.Empty;
|
||||
private bool suppressTreeSelectionChanged;
|
||||
|
||||
private TextBox searchTextBox;
|
||||
private TreeView treeViewControl;
|
||||
@@ -82,6 +83,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
{
|
||||
if (d is HierarchicalSelectionControl control)
|
||||
{
|
||||
control.LogSelectedItemChange(e.NewValue as HierarchicalSelectionItem);
|
||||
control.TryExpandToSelectedItem();
|
||||
}
|
||||
}
|
||||
@@ -111,6 +113,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
EnsureTemplateParts();
|
||||
searchTextBox?.Focus();
|
||||
searchTextBox?.SelectAll();
|
||||
suppressTreeSelectionChanged = false;
|
||||
LogEntry($"[CategoryPicker] DropDownOpened. Selected={SelectedItem?.FullPath ?? "<null>"}");
|
||||
DropDownOpened?.Invoke(this, e);
|
||||
}
|
||||
@@ -118,6 +121,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
private void ComboBoxControl_DropDownClosed(object sender, EventArgs e)
|
||||
{
|
||||
searchDelayTimer.Stop();
|
||||
suppressTreeSelectionChanged = false;
|
||||
LogEntry("[CategoryPicker] DropDownClosed");
|
||||
DropDownClosed?.Invoke(this, e);
|
||||
}
|
||||
@@ -138,6 +142,9 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
private void TreeViewControl_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
||||
{
|
||||
if (suppressTreeSelectionChanged)
|
||||
return;
|
||||
|
||||
if (e.NewValue is HierarchicalSelectionItem selected)
|
||||
{
|
||||
var original = ResolveOriginalItem(selected);
|
||||
@@ -147,6 +154,7 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
LogEntry($"[CategoryPicker] Tree selection changed: {original.FullPath}");
|
||||
}
|
||||
|
||||
suppressTreeSelectionChanged = true;
|
||||
ComboBoxControl.IsDropDownOpen = false;
|
||||
}
|
||||
}
|
||||
@@ -251,7 +259,20 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
private void UpdateDisplaySelection()
|
||||
{
|
||||
// Display handled by ComboBox DisplayMemberPath (FullPath).
|
||||
// Display handled by template TextBlock bound to SelectedItem.FullPath.
|
||||
}
|
||||
|
||||
private void LogSelectedItemChange(HierarchicalSelectionItem newValue)
|
||||
{
|
||||
var description = "<null>";
|
||||
if (newValue != null)
|
||||
{
|
||||
var fullPath = string.IsNullOrWhiteSpace(newValue.FullPath) ? newValue.DisplayName : newValue.FullPath;
|
||||
var id = string.IsNullOrWhiteSpace(newValue.Id) ? "<null>" : newValue.Id;
|
||||
description = $"{fullPath} (Id={id})";
|
||||
}
|
||||
|
||||
LogEntry($"[CategoryPicker] DependencyProperty SelectedItem updated -> {description}");
|
||||
}
|
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user