feat: replace ItemsControl with MultiComboBoxSelectedItemList and add Remove command for selected items
This commit is contained in:
@@ -17,21 +17,13 @@
|
|||||||
CornerRadius="{TemplateBinding CornerRadius}"
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
Background="{DynamicResource TextBoxDefaultBackground}"
|
Background="{DynamicResource TextBoxDefaultBackground}"
|
||||||
BorderBrush="{DynamicResource TextBoxDefaultBorderBrush}">
|
BorderBrush="{DynamicResource TextBoxDefaultBorderBrush}">
|
||||||
<ItemsControl
|
<u:MultiComboBoxSelectedItemList
|
||||||
Name="{x:Static u:MultiAutoCompleteBox.PART_SelectedItemsControl}"
|
Name="{x:Static u:MultiAutoCompleteBox.PART_SelectedItemsControl}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
RemoveCommand="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Remove}"
|
||||||
|
ItemTemplate="{TemplateBinding SelectedItemTemplate}"
|
||||||
ItemsSource="{TemplateBinding SelectedItems}" >
|
ItemsSource="{TemplateBinding SelectedItems}" >
|
||||||
<ItemsControl.ItemTemplate>
|
<u:MultiComboBoxSelectedItemList.ItemsPanel>
|
||||||
<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>
|
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<u:WrapPanelWithTrailingItem>
|
<u:WrapPanelWithTrailingItem>
|
||||||
<u:WrapPanelWithTrailingItem.TrailingItem>
|
<u:WrapPanelWithTrailingItem.TrailingItem>
|
||||||
@@ -39,8 +31,8 @@
|
|||||||
</u:WrapPanelWithTrailingItem.TrailingItem>
|
</u:WrapPanelWithTrailingItem.TrailingItem>
|
||||||
</u:WrapPanelWithTrailingItem>
|
</u:WrapPanelWithTrailingItem>
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ItemsControl.ItemsPanel>
|
</u:MultiComboBoxSelectedItemList.ItemsPanel>
|
||||||
</ItemsControl>
|
</u:MultiComboBoxSelectedItemList>
|
||||||
</Border>
|
</Border>
|
||||||
<Popup
|
<Popup
|
||||||
Name="PART_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.
|
// TODO12: Remove, this shouldn't be part of the public API. Use our internal BindingEvaluator instead.
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A framework element that permits a binding to be evaluated in a new data
|
/// A framework element that permits a binding to be evaluated in a new data
|
||||||
|
|||||||
Reference in New Issue
Block a user