Files
ShrlAlgoToolkit/AntDesignWPF/Styles/Tag.xaml
2025-07-31 20:12:01 +08:00

158 lines
9.7 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:Behaviors="clr-namespace:AntDesign.WPF.Behaviors"
xmlns:controls="clr-namespace:AntDesign.WPF.Controls"
xmlns:helpers="clr-namespace:AntDesign.WPF.Helpers"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AntDesign.WPF;component/Styles/Converters.xaml" />
<ResourceDictionary Source="pack://application:,,,/AntDesign.WPF;component/Styles/Animations.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type controls:Tag}">
<Setter Property="Padding" Value="8,4" />
<Setter Property="Margin" Value="0,0,8,0" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="{DynamicResource TagFontSize}" />
<Setter Property="FontFamily" Value="{DynamicResource FontFamily}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrushBase}" />
<Setter Property="Background" Value="{DynamicResource TagDefaultBackground}" />
<Setter Property="Foreground" Value="{DynamicResource TagDefaultForeground}" />
<Setter Property="BorderThickness" Value="{DynamicResource BorderThicknessBase}" />
<Setter Property="helpers:AntdControl.BorderStyle" Value="{DynamicResource BorderStyleBase}" />
<Setter Property="helpers:AntdControl.CornerRadius" Value="{DynamicResource BorderRadiusBase}" />
<Setter Property="RenderTransformOrigin" Value="0,0.5" />
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform />
</Setter.Value>
</Setter>
<Setter Property="Behaviors:StylizedBehaviors.Behaviors">
<Setter.Value>
<Behaviors:StylizedBehaviorCollection>
<Behaviors:VisibilityBehavior>
<Behaviors:VisibilityBehavior.Appear>
<Storyboard>
<DoubleAnimation
Duration="0:0:0.2"
EasingFunction="{StaticResource EaseInOutCirc}"
From="0"
Storyboard.TargetProperty="Opacity"
To="1" />
</Storyboard>
</Behaviors:VisibilityBehavior.Appear>
<Behaviors:VisibilityBehavior.Leave>
<Storyboard FillBehavior="Stop">
<DoubleAnimation
Duration="0:0:0.3"
EasingFunction="{StaticResource EaseInOutCirc}"
Storyboard.TargetProperty="Opacity"
To="0" />
<DoubleAnimation
Duration="0:0:0.3"
EasingFunction="{StaticResource EaseInOutCirc}"
Storyboard.TargetProperty="RenderTransform.ScaleX"
To="0.2" />
<DoubleAnimation
Duration="0:0:0.3"
EasingFunction="{StaticResource EaseInOutCirc}"
Storyboard.TargetProperty="RenderTransform.ScaleY"
To="0.2" />
</Storyboard>
</Behaviors:VisibilityBehavior.Leave>
</Behaviors:VisibilityBehavior>
</Behaviors:StylizedBehaviorCollection>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Tag}">
<Grid>
<!-- Effect -->
<Border
BorderBrush="{DynamicResource PrimaryBrush}"
BorderThickness="0"
CornerRadius="{TemplateBinding helpers:AntdControl.CornerRadius}"
Focusable="False"
Margin="-1"
Opacity="0.35"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
x:Name="Effect" />
<!-- Border -->
<controls:AntdBorder
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderStyle="{TemplateBinding helpers:AntdControl.BorderStyle}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding helpers:AntdControl.CornerRadius}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True"
x:Name="Border">
<!-- Content -->
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type controls:Icon}" x:Key="Ant.IconClose">
<Setter Property="Opacity" Value="0.65" />
<Setter Property="Margin" Value="3,0,0,0" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="1" />
</Trigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<!-- Content -->
<ColumnDefinition Width="*" />
<!-- Close Button -->
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<controls:Icon
Focusable="False"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Style="{StaticResource Ant.IconClose}"
Type="close"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PART_Close" />
</Grid>
</controls:AntdBorder>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="ColorMode" Value="Colorful">
<Setter Property="BorderBrush" TargetName="Effect" Value="{Binding Foreground, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter Property="Background" TargetName="Border" Value="{Binding Foreground, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ColorPaletteConverter}, ConverterParameter=1}" />
<Setter Property="BorderBrush" TargetName="Border" Value="{Binding Foreground, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ColorPaletteConverter}, ConverterParameter=3}" />
</Trigger>
<Trigger Property="ColorMode" Value="Inverse">
<Setter Property="Foreground" Value="White" />
<Setter Property="BorderBrush" TargetName="Effect" Value="{Binding Background, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
<Setter Property="BorderBrush" TargetName="Border" Value="{Binding Background, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
</Trigger>
<EventTrigger RoutedEvent="MouseLeftButtonUp">
<BeginStoryboard Storyboard="{StaticResource Ant.ClickAnimating}" />
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.85" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>