sourcegit/SourceGit/Resources/Styles/Button.xaml
2020-07-06 10:23:45 +08:00

55 lines
No EOL
2.6 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- 无边框按钮(也是默认样式) -->
<Style x:Key="Style.Button" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="TextElement.Foreground" Value="{DynamicResource Brush.FG}"/>
<Setter Property="Opacity" Value="0.9"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="1"/>
</Trigger>
</Style.Triggers>
</Style>
<!-- 修改默认样式 -->
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource Style.Button}"/>
<!-- 无边框但显示Hover -->
<Style x:Key="Style.Button.HighlightHover" BasedOn="{StaticResource Style.Button}" TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#40000000"/>
</Trigger>
</Style.Triggers>
</Style>
<!-- 有边框 -->
<Style x:Key="Style.Button.Bordered" BasedOn="{StaticResource Style.Button}" TargetType="{x:Type Button}">
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border1}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="8,0"/>
</Style>
<Style x:Key="Style.Button.AccentBordered" BasedOn="{StaticResource Style.Button}" TargetType="{x:Type Button}">
<Setter Property="Background" Value="{DynamicResource Brush.Accent1}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Brush.FG}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="8,0"/>
</Style>
</ResourceDictionary>