Files
ShrlAlgoToolkit/Melskin/Controls/RadioButton.xaml
2026-02-20 15:31:44 +08:00

236 lines
14 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations">
<Style x:Key="EmbossRadioButtonStyle" TargetType="{x:Type RadioButton}">
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="FontSize" Value="14" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid
x:Name="templateRoot"
Background="Transparent"
SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<decorations:EmbossBorder
x:Name="radioButtonBorder"
Width="24"
Height="24"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
CornerRadius="8"
Intensity="0.4"
RenderTransformOrigin="0.5,0.5" />
<decorations:SlotBorder
x:Name="markSlot"
Grid.Column="0"
Width="24"
Height="24"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
CornerRadius="8"
Intensity="0.2"
Visibility="Collapsed">
<Ellipse
x:Name="optionMark"
MinWidth="6"
MinHeight="6"
Margin="1"
Fill="{DynamicResource PrimaryNormalBrush}" />
</decorations:SlotBorder>
<ContentPresenter
x:Name="contentPresenter"
Grid.Column="1"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter TargetName="radioButtonBorder" Property="Visibility" Value="Collapsed" />
<Setter TargetName="markSlot" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="HasContent" Value="true">
<Setter Property="FocusVisualStyle" Value="{DynamicResource OptionMarkFocusVisual}" />
<Setter Property="Padding" Value="4,-1,0,0" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
<Setter TargetName="optionMark" Property="Fill" Value="{DynamicResource PrimaryFocusedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="radioButtonBorder" Property="ShaderEnabled" Value="False" />
<Setter TargetName="radioButtonBorder" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter TargetName="markSlot" Property="ShaderEnabled" Value="False" />
<Setter TargetName="markSlot" Property="ShaderEnabled" Value="False" />
<Setter TargetName="markSlot" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter TargetName="optionMark" Property="Fill" Value="{DynamicResource PrimaryDisabledBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="radioButtonBorder" Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.9" ScaleY="0.9" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type RadioButton}">
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="FontSize" Value="14" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid
x:Name="templateRoot"
Background="Transparent"
SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border
x:Name="radioButtonBorder"
Width="18"
Height="18"
Margin="3,2"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="9"
RenderTransformOrigin="0.5,0.5">
<Grid x:Name="markGrid" Margin="3">
<Ellipse
x:Name="optionMark"
MinWidth="6"
MinHeight="6"
Fill="{DynamicResource PrimaryNormalBrush}"
Opacity="0" />
<Ellipse
x:Name="indeterminateMark"
MinWidth="6"
MinHeight="6"
Opacity="0"
Stroke="{DynamicResource PrimaryNormalBrush}"
StrokeThickness="2" />
</Grid>
</Border>
<ContentPresenter
x:Name="contentPresenter"
Grid.Column="1"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="optionMark" Property="Opacity" Value="1" />
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}">
<Setter TargetName="indeterminateMark" Property="Opacity" Value="1" />
</Trigger>
<Trigger Property="HasContent" Value="true">
<Setter Property="FocusVisualStyle" Value="{DynamicResource OptionMarkFocusVisual}" />
<Setter Property="Padding" Value="4,-1,0,0" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
<Setter TargetName="optionMark" Property="Fill" Value="{DynamicResource PrimaryFocusedBrush}" />
<Setter TargetName="indeterminateMark" Property="Stroke" Value="{DynamicResource PrimaryFocusedBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="radioButtonBorder" Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.9" ScaleY="0.9" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{DynamicResource BorderDisabledBrush}" />
<Setter TargetName="indeterminateMark" Property="Stroke" Value="{DynamicResource PrimaryDisabledBrush}" />
<Setter TargetName="optionMark" Property="Fill" Value="{DynamicResource PrimaryDisabledBrush}" />
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Static ToolBar.RadioButtonStyleKey}" TargetType="{x:Type RadioButton}">
<Setter Property="Margin" Value="1,3" />
<Setter Property="Padding" Value="4,1" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Border
x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4">
<ContentPresenter
x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}" />
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundPressedBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>