Files
ShrlAlgoToolkit/AntDesignWPF/Controls/AntButton/AntButton.xaml

266 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"
2025-07-31 20:12:24 +08:00
xmlns:controls="clr-namespace:AntDesignWPF.Controls"
xmlns:helpers="clr-namespace:AntDesignWPF.Helpers"
2025-07-31 20:12:01 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2025-07-11 09:20:23 +08:00
<ResourceDictionary.MergedDictionaries>
2025-07-31 20:12:24 +08:00
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Converters.xaml" />
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Animations.xaml" />
2025-07-11 09:20:23 +08:00
</ResourceDictionary.MergedDictionaries>
2025-07-31 20:12:24 +08:00
<Style TargetType="{x:Type controls:AntButton}">
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.BackgroundContainer}" />
<Setter Property="BorderBrush" Value="{DynamicResource AntDesign.Brush.BorderPrimary}" />
2025-07-31 20:12:01 +08:00
<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>-->
2025-07-31 20:12:24 +08:00
<Setter Property="ShadowBrush">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource AntDesign.Color.Primary}" Opacity="0.2"/>
</Setter.Value>
</Setter>
<Setter Property="EffectBrush" Value="{DynamicResource AntDesign.Brush.Primary}" />
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}" />
2025-07-31 20:12:24 +08:00
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextPrimary}" />
2025-07-31 20:12:01 +08:00
<Setter Property="Height" Value="{DynamicResource ButtonHeightBase}" />
2025-07-31 20:12:24 +08:00
<Setter Property="helpers:AntControl.BorderStyle" Value="{DynamicResource BorderStyleBase}" />
<Setter Property="helpers:AntControl.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:24 +08:00
<ControlTemplate TargetType="{x:Type controls:AntButton}">
2025-07-11 09:20:23 +08:00
<Grid>
2025-07-31 20:12:24 +08:00
<Border x:Name="Shadow"
Background="{TemplateBinding ShadowBrush}"
Margin="0,0,0,-1"
CornerRadius="{TemplateBinding helpers:AntControl.CornerRadius}" >
<!--<Border.Clip>
<RectangleGeometry Rect="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:AntButton}}, Path=RenderSize}" />
</Border.Clip>-->
2025-07-31 20:12:01 +08:00
</Border>
<!-- Effect -->
<Border
BorderBrush="{TemplateBinding EffectBrush}"
BorderThickness="0"
2025-07-31 20:12:24 +08:00
CornerRadius="{TemplateBinding helpers:AntControl.CornerRadius}"
2025-07-31 20:12:01 +08:00
Focusable="False"
Margin="-1"
Opacity="0.4"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
x:Name="Effect" />
<!-- Border -->
2025-07-31 20:12:24 +08:00
<controls:AntBorder
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
2025-07-31 20:12:24 +08:00
BorderStyle="{TemplateBinding helpers:AntControl.BorderStyle}"
2025-07-31 20:12:01 +08:00
BorderThickness="{TemplateBinding BorderThickness}"
2025-07-31 20:12:24 +08:00
CornerRadius="{TemplateBinding helpers:AntControl.CornerRadius}"
2025-07-31 20:12:01 +08:00
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:24 +08:00
<controls:Icon Grid.Column="0"
2025-07-31 20:12:01 +08:00
Focusable="False"
Margin="0,0,8,0"
2025-07-31 20:12:24 +08:00
VerticalAlignment="Center"
2025-07-31 20:12:01 +08:00
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-31 20:12:24 +08:00
</controls:AntBorder>
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:24 +08:00
<!--<Setter Property="Grid.ColumnSpan" TargetName="Icon" Value="2" />-->
<Setter Property="Visibility" TargetName="Content" Value="Collapsed" />
2025-07-31 20:12:01 +08:00
<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="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-31 20:12:24 +08:00
<Trigger Property="Variant" Value="Solid">
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.Primary}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="EffectBrush" Value="{DynamicResource AntDesign.Brush.Primary}" />
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextOnPrimary}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:24 +08:00
<!-- Outlined -->
<Trigger Property="Variant" Value="Outlined">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource AntDesign.Brush.Primary}" />
<Setter Property="EffectBrush" Value="{DynamicResource AntDesign.Brush.Primary}" />
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.Primary}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:24 +08:00
<!-- Dashed -->
<Trigger Property="Variant" Value="Dashed">
<Setter Property="helpers:AntControl.BorderStyle" Value="Dashed" />
<Setter Property="ShadowBrush" Value="{DynamicResource AntDesign.Brush.Primary}" />
2025-07-31 20:12:01 +08:00
</Trigger>
<!-- Filled -->
2025-07-31 20:12:24 +08:00
<Trigger Property="Variant" Value="Filled">
<Setter Property="Background" >
<Setter.Value>
<SolidColorBrush Color="{DynamicResource AntDesign.Color.Primary}" Opacity="0.2"/>
</Setter.Value>
</Setter>
2025-07-31 20:12:01 +08:00
<Setter Property="BorderBrush" Value="Transparent" />
2025-07-31 20:12:24 +08:00
<Setter Property="EffectBrush" Value="{DynamicResource AntDesign.Brush.BackgroundLayout}" />
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextOnPrimary}" />
2025-07-31 20:12:01 +08:00
</Trigger>
2025-07-31 20:12:24 +08:00
<Trigger Property="Variant" Value="Text">
<Setter Property="Background" Value="Transparent" />
2025-07-31 20:12:01 +08:00
<Setter Property="BorderBrush" Value="Transparent" />
2025-07-31 20:12:24 +08:00
<Setter Property="EffectBrush" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.Primary}" />
2025-07-31 20:12:01 +08:00
</Trigger>
<!-- Link -->
2025-07-31 20:12:24 +08:00
<Trigger Property="Variant" Value="Link">
2025-07-31 20:12:01 +08:00
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
2025-07-31 20:12:24 +08:00
<Setter Property="EffectBrush" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.Primary}" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:24 +08:00
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-31 20:12:24 +08:00
<Setter Property="helpers:AntControl.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:24 +08:00
<Setter Property="helpers:AntControl.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" />
2025-07-31 20:12:24 +08:00
<Condition Property="Variant" Value="Solid" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.Primary}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Variant" Value="Solid" />
<Condition Property="Color" Value="Danger" />
2025-07-11 09:20:23 +08:00
</MultiTrigger.Conditions>
2025-07-31 20:12:24 +08:00
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.Error}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="EffectBrush" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextPrimary}" />
2025-07-11 09:20:23 +08:00
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Ghost" Value="True" />
2025-07-31 20:12:24 +08:00
<!--<Condition Property="Type" Value="Danger" />-->
2025-07-11 09:20:23 +08:00
</MultiTrigger.Conditions>
2025-07-31 20:12:24 +08:00
<Setter Property="BorderBrush" Value="{DynamicResource AntDesign.Brush.BackgroundLayout}" />
2025-07-11 09:20:23 +08:00
</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>
2025-07-31 20:12:24 +08:00
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.BackgroundLayout}" />
<Setter Property="BorderBrush" Value="{DynamicResource AntDesign.Brush.BorderPrimary}" />
<Setter Property="Foreground" Value="{DynamicResource AntDesign.Brush.TextQuaternary}" />
2025-07-11 09:20:23 +08:00
</MultiTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>