feat: replace ItemsControl with MultiComboBoxSelectedItemList and add Remove command for selected items
This commit is contained in:
@@ -17,21 +17,13 @@
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Background="{DynamicResource TextBoxDefaultBackground}"
|
||||
BorderBrush="{DynamicResource TextBoxDefaultBorderBrush}">
|
||||
<ItemsControl
|
||||
<u:MultiComboBoxSelectedItemList
|
||||
Name="{x:Static u:MultiAutoCompleteBox.PART_SelectedItemsControl}"
|
||||
VerticalAlignment="Center"
|
||||
RemoveCommand="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Remove}"
|
||||
ItemTemplate="{TemplateBinding SelectedItemTemplate}"
|
||||
ItemsSource="{TemplateBinding SelectedItems}" >
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<!-- TODO: Update command. -->
|
||||
<u:ClosableTag
|
||||
Content="{Binding .}"
|
||||
Command="{Binding $parent[u:TagInput].Close}"
|
||||
ContentTemplate="{Binding $parent[u:MultiAutoCompleteBox].SelectedItemTemplate}"
|
||||
></u:ClosableTag>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<u:MultiComboBoxSelectedItemList.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<u:WrapPanelWithTrailingItem>
|
||||
<u:WrapPanelWithTrailingItem.TrailingItem>
|
||||
@@ -39,8 +31,8 @@
|
||||
</u:WrapPanelWithTrailingItem.TrailingItem>
|
||||
</u:WrapPanelWithTrailingItem>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
</u:MultiComboBoxSelectedItemList.ItemsPanel>
|
||||
</u:MultiComboBoxSelectedItemList>
|
||||
</Border>
|
||||
<Popup
|
||||
Name="PART_Popup"
|
||||
|
||||
@@ -1879,6 +1879,15 @@ public partial class MultiAutoCompleteBox : TemplatedControl, IInnerContentContr
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(object? o)
|
||||
{
|
||||
if (o is not StyledElement s) return;
|
||||
if (SelectedItems?.Contains(s.DataContext) == true)
|
||||
{
|
||||
SelectedItems.Remove(s.DataContext);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO12: Remove, this shouldn't be part of the public API. Use our internal BindingEvaluator instead.
|
||||
/// <summary>
|
||||
/// A framework element that permits a binding to be evaluated in a new data
|
||||
|
||||
Reference in New Issue
Block a user