feat: add closing feature.

This commit is contained in:
rabbitism
2023-06-29 02:25:31 +08:00
parent 9d249b01cd
commit 2d353ad9e0
5 changed files with 129 additions and 20 deletions

View File

@@ -9,10 +9,7 @@
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="ItemTemplate">
<DataTemplate>
<Label
Classes="Solid"
Content="{Binding}"
Theme="{DynamicResource TagLabel}" />
<u:ClosableTag Command="{Binding $parent[u:TagInput].Close}" Content="{Binding}" />
</DataTemplate>
</Setter>
<Setter Property="Template">
@@ -24,6 +21,7 @@
CornerRadius="3">
<Panel HorizontalAlignment="Stretch">
<ItemsControl
Name="PART_ItemsControl"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
ItemTemplate="{TemplateBinding ItemTemplate}"
@@ -84,4 +82,34 @@
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:ClosableTag}" TargetType="u:ClosableTag">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<ControlTemplate TargetType="u:ClosableTag">
<Border
Margin="1"
Background="Transparent"
BorderBrush="Black"
BorderThickness="1"
CornerRadius="3">
<DockPanel LastChildFill="True">
<PathIcon
Name="{x:Static u:ClosableTag.PART_CloseButton}"
Width="8"
Height="8"
Background="Transparent"
Data="M17.6568 19.7782C18.2426 20.3639 19.1924 20.3639 19.7782 19.7782C20.3639 19.1924 20.3639 18.2426 19.7782 17.6568L14.1213 12L19.7782 6.34313C20.3639 5.75734 20.3639 4.8076 19.7782 4.22181C19.1924 3.63602 18.2426 3.63602 17.6568 4.22181L12 9.87866L6.34313 4.22181C5.75734 3.63602 4.8076 3.63602 4.22181 4.22181C3.63602 4.8076 3.63602 5.75734 4.22181 6.34313L9.87866 12L4.22181 17.6568C3.63602 18.2426 3.63602 19.1924 4.22181 19.7782C4.8076 20.3639 5.75734 20.3639 6.34313 19.7782L12 14.1213L17.6568 19.7782Z"
DockPanel.Dock="Right" />
<TextBlock
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
FontSize="12"
Text="{TemplateBinding Content}"
TextTrimming="CharacterEllipsis" />
</DockPanel>
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>