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

98 lines
5.3 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 Button}">
<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="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<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>
</Style.Triggers>
</Style>
<Style x:Key="SharpButtonStyle"
BasedOn="{StaticResource {x:Type Button}}"
TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<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="BacklessButtonStyle"
BasedOn="{StaticResource SharpButtonStyle}"
TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="IsTabStop" Value="False" />
<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="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.6" />
<Setter Property="Background" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>