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

138 lines
8.3 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AntDesign.WPF;component/Styles/Animations.xaml" />
<ResourceDictionary Source="pack://application:,,,/AntDesign.WPF;component/Styles/Control.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style
BasedOn="{StaticResource Ant.Control}"
TargetType="{x:Type RadioButton}"
x:Key="Ant.RadioButton">
<Setter Property="Padding" Value="4,0,8,0" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrushBase}" />
<Setter Property="Background" Value="{DynamicResource RadioButtonBackground}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Effect -->
<Ellipse
Height="{DynamicResource RadioSize}"
Opacity="0"
RenderTransformOrigin="0.5,0.5"
Stroke="{DynamicResource RadioDotBrush}"
StrokeThickness="{TemplateBinding BorderThickness}"
Width="{DynamicResource RadioSize}"
x:Name="Effect">
<Ellipse.RenderTransform>
<ScaleTransform ScaleX="1" ScaleY="1" />
</Ellipse.RenderTransform>
</Ellipse>
<!-- Circle -->
<Ellipse
Fill="{TemplateBinding Background}"
Height="{DynamicResource RadioSize}"
Stroke="{TemplateBinding BorderBrush}"
StrokeThickness="{TemplateBinding BorderThickness}"
Width="{DynamicResource RadioSize}"
x:Name="Inner" />
<Ellipse
Fill="{DynamicResource RadioDotBrush}"
Height="{DynamicResource RadioDotSize}"
Opacity="0"
RenderTransformOrigin="0.5,0.5"
Width="{DynamicResource RadioDotSize}"
x:Name="Dot">
<Ellipse.RenderTransform>
<ScaleTransform ScaleX="0" ScaleY="0" />
</Ellipse.RenderTransform>
</Ellipse>
<!-- Content -->
<ContentPresenter
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Checked">
<Storyboard>
<DoubleAnimation
Duration="0:0:0.2"
EasingFunction="{StaticResource EaseInOutCirc}"
Storyboard.TargetName="Dot"
Storyboard.TargetProperty="Opacity"
To="1" />
<DoubleAnimation
Duration="0:0:0.2"
EasingFunction="{StaticResource EaseInOutCirc}"
Storyboard.TargetName="Dot"
Storyboard.TargetProperty="RenderTransform.ScaleX"
To="1" />
<DoubleAnimation
Duration="0:0:0.2"
EasingFunction="{StaticResource EaseInOutCirc}"
Storyboard.TargetName="Dot"
Storyboard.TargetProperty="RenderTransform.ScaleY"
To="1" />
<!-- Effect -->
<DoubleAnimation
Duration="0:0:0.36"
EasingFunction="{StaticResource EaseInOut}"
From="0.4"
Storyboard.TargetName="Effect"
Storyboard.TargetProperty="Opacity"
To="0" />
<DoubleAnimation
Duration="0:0:0.36"
EasingFunction="{StaticResource EaseInOut}"
Storyboard.TargetName="Effect"
Storyboard.TargetProperty="RenderTransform.ScaleX"
To="1.6" />
<DoubleAnimation
Duration="0:0:0.36"
EasingFunction="{StaticResource EaseInOut}"
Storyboard.TargetName="Effect"
Storyboard.TargetProperty="RenderTransform.ScaleY"
To="1.6" />
</Storyboard>
</VisualState>
<VisualState x:Name="Unchecked" />
<VisualState x:Name="Indeterminate" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Stroke" TargetName="Inner" Value="{DynamicResource RadioDotBrush}" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Stroke" TargetName="Inner" Value="{DynamicResource RadioDotBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Fill" TargetName="Dot" Value="#CCCCCC" />
<Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
<Setter Property="Fill" TargetName="Inner" Value="{DynamicResource InputDisabledBackground}" />
<Setter Property="Stroke" TargetName="Inner" Value="{DynamicResource BorderBrushBase}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>