Files
ShrlAlgoToolkit/AntDesignWPF/Styles/Button.xaml

258 lines
16 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:AntDesign.WPF.Controls"
xmlns:helpers="clr-namespace:AntDesign.WPF.Helpers"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2025-07-11 09:20:23 +08:00
<ResourceDictionary.MergedDictionaries>
2025-07-31 20:12:01 +08:00
<ResourceDictionary Source="pack://application:,,,/AntDesign.WPF;component/Styles/Converters.xaml" />
<ResourceDictionary Source="pack://application:,,,/AntDesign.WPF;component/Styles/Animations.xaml" />
2025-07-11 09:20:23 +08:00
</ResourceDictionary.MergedDictionaries>
2025-07-31 20:12:01 +08:00
<Style TargetType="{x:Type controls:AntdButton}">
<Setter Property="Background" Value="{DynamicResource ButtonDefaultBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonDefaultBorder}" />
<Setter Property="BorderThickness" Value="{DynamicResource BorderThicknessBase}" />
<!-- <Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Color="Black"
BlurRadius="10"
Direction="270"
Opacity="0.4"
ShadowDepth="5" />
</Setter.Value>
</Setter>-->
<Setter Property="EffectBrush" Value="{DynamicResource PrimaryBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
2025-07-31 20:12:01 +08:00
<Setter Property="Cursor" Value="Hand" />
2025-07-11 09:20:23 +08:00
<Setter Property="FontSize" Value="{DynamicResource FontSizeBase}" />
<Setter Property="FontWeight" Value="{DynamicResource ButtonFontWeight}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonDefaultForeground}" />
2025-07-31 20:12:01 +08:00
<Setter Property="Height" Value="{DynamicResource ButtonHeightBase}" />
2025-07-12 23:31:32 +08:00
<Setter Property="helpers:AntdControl.BorderStyle" Value="{DynamicResource BorderStyleBase}" />
<Setter Property="helpers:AntdControl.CornerRadius" Value="{DynamicResource ButtonBorderRadiusBase}" />
2025-07-31 20:12:01 +08:00
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="{DynamicResource ButtonPaddingBase}" />
<Setter Property="SnapsToDevicePixels" Value="True" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
2025-07-31 20:12:01 +08:00
<ControlTemplate TargetType="{x:Type controls:AntdButton}">
2025-07-11 09:20:23 +08:00
<Grid>
2025-07-31 20:12:01 +08:00
<Border
Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding helpers:AntdControl.CornerRadius}"
Margin="0,6,0,0"
Opacity="0.25"
Panel.ZIndex="0"
RenderTransformOrigin="0.5,0.5"
x:Name="ReflectionLayer">
<Border.RenderTransform>
<ScaleTransform ScaleX="1.02" ScaleY="1.03" />
</Border.RenderTransform>
</Border>
<!-- Effect -->
<Border
BorderBrush="{TemplateBinding EffectBrush}"
BorderThickness="0"
CornerRadius="{TemplateBinding helpers:AntdControl.CornerRadius}"
Focusable="False"
Margin="-1"
Opacity="0.4"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
x:Name="Effect" />
<!-- Border -->
<Border
Background="Black"
CornerRadius="4"
Height="40"
HorizontalAlignment="Left"
Margin="4,4,0,0"
Opacity="0.2"
VerticalAlignment="Top"
Width="120" />
<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="PART_Border">
<!-- Content -->
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
2025-07-11 09:20:23 +08:00
<Grid.ColumnDefinitions>
2025-07-31 20:12:01 +08:00
<!-- Icon -->
2025-07-11 09:20:23 +08:00
<ColumnDefinition Width="Auto" />
2025-07-31 20:12:01 +08:00
<!-- Content -->
2025-07-11 09:20:23 +08:00
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
2025-07-31 20:12:01 +08:00
<controls:Icon
Focusable="False"
Margin="0,0,8,0"
Type="{TemplateBinding Icon}"
x:Name="Icon" />
<ContentPresenter
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
Grid.Column="1"
RecognizesAccessKey="True"
x:Name="Content" />
2025-07-11 09:20:23 +08:00
</Grid>
2025-07-12 23:31:32 +08:00
</controls:AntdBorder>
2025-07-11 09:20:23 +08:00
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0" To="Pressed" />
<VisualTransition GeneratedDuration="0:0:0.3" GeneratedEasingFunction="{StaticResource EaseInOut}" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver" />
<VisualState x:Name="Pressed" />
<VisualState x:Name="Disabled" />
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.3" GeneratedEasingFunction="{StaticResource EaseInOut}" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Focused" />
<VisualState x:Name="Unfocused" />
</VisualStateGroup>
<VisualStateGroup x:Name="LoadStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.2" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Loaded">
<Storyboard>
2025-07-31 20:12:01 +08:00
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.65" />
2025-07-11 09:20:23 +08:00
</Storyboard>
</VisualState>
<VisualState x:Name="Unloaded" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
2025-07-31 20:12:01 +08:00
<!-- Loading State -->
2025-07-11 09:20:23 +08:00
<Trigger Property="Loading" Value="True">
2025-07-31 20:12:01 +08:00
<Setter Property="Type" TargetName="Icon" Value="loading" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- Content State -->
2025-07-11 09:20:23 +08:00
<Trigger Property="Content" Value="{x:Null}">
2025-07-31 20:12:01 +08:00
<Setter Property="Grid.ColumnSpan" TargetName="Icon" Value="2" />
<Setter Property="Margin" TargetName="Icon" Value="0" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<Trigger Property="Type" SourceName="Icon" Value="{x:Null}">
<Setter Property="Grid.Column" TargetName="Content" Value="0" />
<Setter Property="Grid.ColumnSpan" TargetName="Content" Value="2" />
<Setter Property="Visibility" TargetName="Icon" Value="Collapsed" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- Shape Circle -->
2025-07-11 09:20:23 +08:00
<Trigger Property="Shape" Value="Circle">
2025-07-31 20:12:01 +08:00
<Setter Property="FontSize" TargetName="Icon" Value="{Binding FontSize, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource AdditionConverter}, ConverterParameter=2}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<EventTrigger RoutedEvent="ButtonBase.Click">
<BeginStoryboard Storyboard="{StaticResource Ant.ClickAnimating}" />
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
2025-07-31 20:12:01 +08:00
<Setter Property="VerticalContentAlignment" Value="Center" />
2025-07-11 09:20:23 +08:00
<Style.Triggers>
2025-07-31 20:12:01 +08:00
<!-- Ghost State -->
2025-07-11 09:20:23 +08:00
<Trigger Property="Ghost" Value="True">
<Setter Property="Background" Value="Transparent" />
2025-07-31 20:12:01 +08:00
<Setter Property="BorderBrush" Value="White" />
<Setter Property="Foreground" Value="White" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- Primary -->
2025-07-11 09:20:23 +08:00
<Trigger Property="Type" Value="Primary">
<Setter Property="Background" Value="{DynamicResource ButtonPrimaryBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonPrimaryBackground}" />
2025-07-31 20:12:01 +08:00
<Setter Property="EffectBrush" Value="{DynamicResource ButtonPrimaryBackground}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonPrimaryForeground}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- Dashed -->
2025-07-11 09:20:23 +08:00
<Trigger Property="Type" Value="Dashed">
2025-07-12 23:31:32 +08:00
<Setter Property="helpers:AntdControl.BorderStyle" Value="Dashed" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- Danger -->
2025-07-11 09:20:23 +08:00
<Trigger Property="Type" Value="Danger">
2025-07-31 20:12:01 +08:00
<Setter Property="Background" Value="{DynamicResource ButtonDangerBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonDangerBorder}" />
2025-07-11 09:20:23 +08:00
<Setter Property="EffectBrush" Value="{DynamicResource ButtonDangerForeground}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonDangerForeground}" />
2025-07-31 20:12:01 +08:00
</Trigger>
<!-- Filled -->
<Trigger Property="Type" Value="Filled">
2025-07-11 09:20:23 +08:00
<Setter Property="Background" Value="{DynamicResource ButtonDangerBackground}" />
2025-07-31 20:12:01 +08:00
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="EffectBrush" Value="{DynamicResource ButtonDangerForeground}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonPrimaryForeground}" />
</Trigger>
<Trigger Property="Type" Value="Text">
<Setter Property="Background" Value="{DynamicResource ButtonDangerBackground}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="EffectBrush" Value="{DynamicResource ButtonDangerForeground}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonPrimaryForeground}" />
</Trigger>
<!-- Link -->
<Trigger Property="Type" Value="Link">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="EffectBrush" Value="{DynamicResource ButtonDangerForeground}" />
<Setter Property="Foreground" Value="{DynamicResource LinkActiveBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- Size -->
2025-07-11 09:20:23 +08:00
<Trigger Property="Size" Value="Large">
2025-07-31 20:12:01 +08:00
<Setter Property="FontSize" Value="{DynamicResource ButtonFontSizeLarge}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Height" Value="{DynamicResource ButtonHeightLarge}" />
<Setter Property="Padding" Value="{DynamicResource ButtonPaddingLarge}" />
</Trigger>
<Trigger Property="Size" Value="Small">
<Setter Property="FontSize" Value="{DynamicResource ButtonFontSizeSmall}" />
2025-07-31 20:12:01 +08:00
<Setter Property="Height" Value="{DynamicResource ButtonHeightSmall}" />
2025-07-12 23:31:32 +08:00
<Setter Property="helpers:AntdControl.CornerRadius" Value="{DynamicResource ButtonBorderRadiusSmall}" />
2025-07-31 20:12:01 +08:00
<Setter Property="Padding" Value="{DynamicResource ButtonPaddingSmall}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- Shape Circle -->
2025-07-11 09:20:23 +08:00
<Trigger Property="Shape" Value="Circle">
2025-07-31 20:12:01 +08:00
<Setter Property="helpers:AntdControl.CornerRadius" Value="{Binding Height, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource DoubleToCornerRadiusConverter}, ConverterParameter=2}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Padding" Value="0" />
<Setter Property="Width" Value="{Binding Height, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- Loading State -->
2025-07-11 09:20:23 +08:00
<Trigger Property="Loading" Value="True">
<Setter Property="IsEnabled" Value="False" />
</Trigger>
2025-07-31 20:12:01 +08:00
<!-- Ghost States -->
2025-07-11 09:20:23 +08:00
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Ghost" Value="True" />
<Condition Property="Type" Value="Primary" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{DynamicResource ButtonPrimaryBackground}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Ghost" Value="True" />
<Condition Property="Type" Value="Danger" />
</MultiTrigger.Conditions>
<Setter Property="BorderBrush" Value="{DynamicResource ButtonDangerForeground}" />
</MultiTrigger>
2025-07-31 20:12:01 +08:00
<!-- Disabled -->
2025-07-11 09:20:23 +08:00
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Loading" Value="False" />
<Condition Property="IsEnabled" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="{DynamicResource ButtonDisableBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonDisableBorder}" />
2025-07-31 20:12:01 +08:00
<Setter Property="Foreground" Value="{DynamicResource ButtonDisableForeground}" />
2025-07-11 09:20:23 +08:00
</MultiTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>