feat: adjust CheckBox Border style.

This commit is contained in:
Zhang Dian 2023-06-05 22:47:00 +08:00
parent 6d3514308a
commit 7a040120b5
4 changed files with 52 additions and 47 deletions

View File

@ -4,11 +4,11 @@
x:CompileBindings="True">
<ControlTheme x:Key="{x:Type CheckBox}" TargetType="CheckBox">
<Setter Property="Padding" Value="8,0,0,0" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="FontSize" Value="{DynamicResource CheckBoxFontSize}" />
<Setter Property="CornerRadius" Value="{DynamicResource CheckBoxBoxCornerRadius}" />
<Setter Property="MinHeight" Value="32" />
@ -17,50 +17,45 @@
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxDefaultBorderBrush}" />
<Setter Property="Template">
<ControlTemplate TargetType="CheckBox">
<Grid x:Name="RootGrid" ColumnDefinitions="Auto,*">
<Border
x:Name="PART_Border"
Grid.Column="0"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" />
<Grid
Grid.Column="0"
Margin="0,0,0,0"
VerticalAlignment="Center">
<Border
x:Name="NormalRectangle"
Width="{DynamicResource CheckBoxBoxWidth}"
Height="{DynamicResource CheckBoxBoxHeight}"
Background="{DynamicResource CheckBoxDefaultBackground}"
BorderBrush="{DynamicResource CheckBoxDefaultBorderBrush}"
BorderThickness="{DynamicResource CheckBoxBoxBorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
UseLayoutRounding="False" />
<PathIcon
Name="CheckGlyph"
Width="{DynamicResource CheckBoxBoxGlyphWidth}"
Height="{DynamicResource CheckBoxBoxGlyphHeight}"
Foreground="{DynamicResource CheckBoxGlyphFill}" />
<Border
x:Name="RootBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Grid x:Name="RootGrid" ColumnDefinitions="Auto,*">
<Grid
Grid.Column="0"
Margin="0,0,0,0"
VerticalAlignment="Center">
<Border
x:Name="NormalRectangle"
Width="{DynamicResource CheckBoxBoxWidth}"
Height="{DynamicResource CheckBoxBoxHeight}"
Background="{DynamicResource CheckBoxDefaultBackground}"
BorderBrush="{DynamicResource CheckBoxDefaultBorderBrush}"
BorderThickness="{DynamicResource CheckBoxBoxBorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
UseLayoutRounding="False" />
<PathIcon
Name="CheckGlyph"
Width="{DynamicResource CheckBoxBoxGlyphWidth}"
Height="{DynamicResource CheckBoxBoxGlyphHeight}"
Foreground="{DynamicResource CheckBoxGlyphFill}" />
</Grid>
<ContentPresenter
x:Name="ContentPresenter"
Grid.Column="1"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
IsVisible="{TemplateBinding Content,Converter={x:Static ObjectConverters.IsNotNull}}"
RecognizesAccessKey="True"
TextWrapping="Wrap" />
</Grid>
<ContentPresenter
x:Name="ContentPresenter"
Grid.Column="1"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
IsVisible="{TemplateBinding Content,
Converter={x:Static ObjectConverters.IsNotNull}}"
RecognizesAccessKey="True"
TextWrapping="Wrap" />
</Grid>
</Border>
</ControlTemplate>
</Setter>
@ -461,4 +456,4 @@
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>
</ResourceDictionary>

View File

@ -24,6 +24,10 @@
<Setter Property="RadioButton.HorizontalContentAlignment" Value="Left" />
<Setter Property="RadioButton.VerticalContentAlignment" Value="Center" />
<Setter Property="RadioButton.FontSize" Value="{DynamicResource RadioButtonFontSize}" />
<Setter Property="RadioButton.CornerRadius" Value="{DynamicResource RadioButtonBoxCornerRadius}" />
<Setter Property="RadioButton.Foreground" Value="{DynamicResource RadioButtonForeground}" />
<Setter Property="RadioButton.Background" Value="{DynamicResource RadioButtonDefaultBackground}" />
<Setter Property="RadioButton.BorderBrush" Value="{DynamicResource RadioButtonDefaultBorderBrush}" />
<Setter Property="Template">
<ControlTemplate TargetType="RadioButton">
<Border

View File

@ -32,6 +32,9 @@
<SolidColorBrush x:Key="RadioButtonCheckGlyphFill" Color="White" />
<SolidColorBrush x:Key="RadioButtonForeground" Color="#F9F9F9" />
<SolidColorBrush x:Key="RadioButtonDefaultBackground" Color="Transparent" />
<SolidColorBrush x:Key="RadioButtonDefaultBorderBrush" Opacity="0.35" Color="#F9F9F9" />
<CornerRadius x:Key="RadioButtonBoxCornerRadius">3</CornerRadius>
<SolidColorBrush x:Key="RadioButtonGroupBackground" Opacity="0.12" Color="White" />

View File

@ -32,6 +32,9 @@
<SolidColorBrush x:Key="RadioButtonCheckGlyphFill" Color="White" />
<SolidColorBrush x:Key="RadioButtonForeground" Color="#1C1F23" />
<SolidColorBrush x:Key="RadioButtonDefaultBackground" Color="Transparent" />
<SolidColorBrush x:Key="RadioButtonDefaultBorderBrush" Opacity="0.35" Color="#1C1F23" />
<CornerRadius x:Key="RadioButtonBoxCornerRadius">3</CornerRadius>
<SolidColorBrush x:Key="RadioButtonGroupBackground" Opacity="0.05" Color="#2E3238" />