feat: add CornerRadius property to MultiAutoCompleteBox and improve focus handling logic
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
<ControlTheme x:Key="{x:Type u:MultiAutoCompleteBox}" TargetType="u:MultiAutoCompleteBox">
|
<ControlTheme x:Key="{x:Type u:MultiAutoCompleteBox}" TargetType="u:MultiAutoCompleteBox">
|
||||||
<Setter Property="MinHeight" Value="{DynamicResource AutoCompleteBoxDefaultHeight}" />
|
<Setter Property="MinHeight" Value="{DynamicResource AutoCompleteBoxDefaultHeight}" />
|
||||||
<Setter Property="MaxDropDownHeight" Value="{DynamicResource AutoCompleteMaxDropdownHeight}" />
|
<Setter Property="MaxDropDownHeight" Value="{DynamicResource AutoCompleteMaxDropdownHeight}" />
|
||||||
|
<Setter Property="CornerRadius" Value="{DynamicResource TextBoxDefaultCornerRadius}"></Setter>
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate TargetType="u:MultiAutoCompleteBox">
|
<ControlTemplate TargetType="u:MultiAutoCompleteBox">
|
||||||
<Panel>
|
<Panel>
|
||||||
@@ -13,10 +14,12 @@
|
|||||||
MinHeight="30"
|
MinHeight="30"
|
||||||
Padding="{DynamicResource TextBoxContentPadding}"
|
Padding="{DynamicResource TextBoxContentPadding}"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
Background="{DynamicResource TextBoxDefaultBackground}"
|
Background="{DynamicResource TextBoxDefaultBackground}"
|
||||||
BorderBrush="{DynamicResource TextBoxDefaultBorderBrush}">
|
BorderBrush="{DynamicResource TextBoxDefaultBorderBrush}">
|
||||||
<ItemsControl
|
<ItemsControl
|
||||||
Name="{x:Static u:MultiAutoCompleteBox.PART_SelectedItemsControl}"
|
Name="{x:Static u:MultiAutoCompleteBox.PART_SelectedItemsControl}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
ItemsSource="{TemplateBinding SelectedItems}" >
|
ItemsSource="{TemplateBinding SelectedItems}" >
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
|||||||
@@ -536,14 +536,11 @@ public partial class MultiAutoCompleteBox : TemplatedControl, IInnerContentContr
|
|||||||
if (selector != null)
|
if (selector != null)
|
||||||
{
|
{
|
||||||
// Check if it is already an IItemsSelector
|
// Check if it is already an IItemsSelector
|
||||||
adapter = selector as ISelectionAdapter;
|
// Built in support for wrapping a Selector control
|
||||||
if (adapter == null)
|
adapter = new MultiAutoCompleteSelectionAdapter(selector);
|
||||||
// Built in support for wrapping a Selector control
|
|
||||||
adapter = new MultiAutoCompleteSelectionAdapter(selector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adapter == null) adapter = nameScope.Find<ISelectionAdapter>(ElementSelectionAdapter);
|
return adapter ?? nameScope.Find<ISelectionAdapter>(ElementSelectionAdapter);
|
||||||
return adapter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -745,8 +742,7 @@ public partial class MultiAutoCompleteBox : TemplatedControl, IInnerContentContr
|
|||||||
// Check if we still have focus in the parent's focus scope
|
// Check if we still have focus in the parent's focus scope
|
||||||
if (GetFocusScope() is { } scope &&
|
if (GetFocusScope() is { } scope &&
|
||||||
(TopLevel.GetTopLevel(this)?.FocusManager?.GetFocusedElement() is not { } focused ||
|
(TopLevel.GetTopLevel(this)?.FocusManager?.GetFocusedElement() is not { } focused ||
|
||||||
(focused != this &&
|
(focused != this && focused is not ListBoxItem && focused is Visual v && !this.IsVisualAncestorOf(v))))
|
||||||
focused is Visual v && !this.IsVisualAncestorOf(v))))
|
|
||||||
SetCurrentValue(IsDropDownOpenProperty, false);
|
SetCurrentValue(IsDropDownOpenProperty, false);
|
||||||
|
|
||||||
_userCalledPopulate = false;
|
_userCalledPopulate = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user