Kategorie
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -2392,25 +2392,23 @@ namespace FasdDesktopUi.Basics.UserControls
|
||||
|
||||
|
||||
#region DropDown
|
||||
private static bool IsInsidePageable(FrameworkElement fe)
|
||||
{
|
||||
return cUiElementHelper.GetFirstParentOfType<ComboBoxPageable>(fe) != null;
|
||||
}
|
||||
private static bool IsInsidePageable(FrameworkElement fe) => cUiElementHelper.GetFirstParentOfType<ComboBoxPageable>(fe) != null;
|
||||
private static bool IsHierarchicalControl(FrameworkElement fe) => fe is HierarchicalSelectionControl;
|
||||
|
||||
private void DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
if (!(sender is FrameworkElement fe)) return;
|
||||
if (IsInsidePageable(fe)) return; // ComboBoxPageable macht das selbst
|
||||
|
||||
var parentBorder = cUiElementHelper.GetFirstParentOfType<Border>(fe);
|
||||
if (parentBorder != null)
|
||||
if (!(sender is FrameworkElement fe)) return;
|
||||
if (IsInsidePageable(fe) || IsHierarchicalControl(fe)) return; // Spezialfälle handeln Fokus selbst
|
||||
|
||||
var parentBorder = cUiElementHelper.GetFirstParentOfType<Border>(fe);
|
||||
if (parentBorder != null)
|
||||
cFocusInvoker.InvokeGotFocus(parentBorder, e);
|
||||
}
|
||||
|
||||
private void DropDownClosed(object sender, EventArgs e)
|
||||
{
|
||||
if (!(sender is FrameworkElement fe)) return;
|
||||
if (IsInsidePageable(fe)) return;
|
||||
if (!(sender is FrameworkElement fe)) return;
|
||||
if (IsInsidePageable(fe) || IsHierarchicalControl(fe)) return;
|
||||
|
||||
var parentBorder = cUiElementHelper.GetFirstParentOfType<Border>(fe);
|
||||
if (parentBorder != null)
|
||||
|
||||
Reference in New Issue
Block a user