Files
ShrlAlgoToolkit/WPFDark/StandardControls/ToggleButton.xaml
ShrlAlgo 4d35cadb56 更新
2025-07-11 09:20:23 +08:00

130 lines
7.2 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wpf="clr-namespace:WPFDark">
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundBrushKey}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushKey}" />
<Setter Property="Foreground" Value="{DynamicResource ForegroundBrushKey}" />
<Setter Property="Padding">
<Setter.Value>
<Thickness Bottom="{x:Static wpf:Boxes.ButtonPaddingY}"
Left="{x:Static wpf:Boxes.ButtonPaddingX}"
Right="{x:Static wpf:Boxes.ButtonPaddingX}"
Top="{x:Static wpf:Boxes.ButtonPaddingY}" />
</Setter.Value>
</Setter>
<Setter Property="Height" Value="{x:Static wpf:Boxes.BasicOneLineHeight}" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0"
CornerRadius="{x:Static wpf:Boxes.BasicCornerRadius}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True">
<ContentPresenter Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource ButtonActiveBackgroundBrushKey}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonActiveBorderBrushKey}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonActiveForegroundBrushKey}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource ButtonPressedBackgroundBrushKey}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonPressedBorderBrushKey}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonPressedForegroundBrushKey}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="{DynamicResource ButtonInactiveBackgroundBrushKey}" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonInactiveBorderBrushKey}" />
<Setter Property="Foreground" Value="{DynamicResource InactiveForegroundBrushKey}" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundBrushKey.IsChecked}" />
<Setter Property="Foreground" Value="{DynamicResource AccentForegroundBrushKey}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundBrushKey.IsChecked.IsMouseOver}" />
<Setter Property="Foreground" Value="{DynamicResource AccentForegroundBrushKey}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True" />
<Condition Property="IsEnabled" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="{DynamicResource ToggleButtonBackgroundBrushKey.IsChecked.IsDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource ButtonInactiveForegroundBrushKey}" />
</MultiTrigger>
</Style.Triggers>
</Style>
<Style x:Key="SharpToggleButtonStyle"
BasedOn="{StaticResource {x:Type ToggleButton}}"
TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True">
<ContentPresenter Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="BacklessToggleButtonStyle"
BasedOn="{StaticResource SharpToggleButtonStyle}"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource ActiveBackgroundBrushKey}" />
<Setter Property="BorderBrush" Value="{DynamicResource ActiveBorderBrushKey}" />
<Setter Property="Foreground" Value="{DynamicResource AccentBrushKey}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource AccentBrushKey}" />
<Setter Property="BorderBrush" Value="{DynamicResource ActiveBorderBrushKey}" />
<Setter Property="Foreground" Value="{DynamicResource AccentForegroundBrushKey}" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="{DynamicResource AccentBrushKey}" />
<Setter Property="BorderBrush" Value="{DynamicResource ActiveBorderBrushKey}" />
<Setter Property="Foreground" Value="{DynamicResource AccentForegroundBrushKey}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.6" />
<Setter Property="Background" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>