feat: add SimpleToggleSwitch theme.

This commit is contained in:
Zhang Dian
2023-02-22 17:37:39 +08:00
parent 4e48f28e1c
commit 20f421f6fc
2 changed files with 60 additions and 13 deletions

View File

@@ -123,17 +123,22 @@
<Setter Property="ContentPresenter.IsVisible" Value="True" />
</Style>
<Style Selector="^ /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerUnCheckedDefaultBackground}" />
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerUnCheckedDefaultBackground}" />
</Style>
<Style Selector="^:pointerover /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerUnCheckedPointerOverBackground}" />
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerUnCheckedPointerOverBackground}" />
</Style>
<Style Selector="^:pressed /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerUnCheckedPressedBackground}" />
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerUnCheckedPressedBackground}" />
</Style>
<Style Selector="^:disabled /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerUnCheckedDisabledBackground}" />
<Setter Property="Border.BorderBrush" Value="{DynamicResource ToggleSwitchContainerUnCheckedDisabledBorderBrush}" />
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerUnCheckedDisabledBackground}" />
<Setter Property="Border.BorderBrush"
Value="{DynamicResource ToggleSwitchContainerUnCheckedDisabledBorderBrush}" />
<Setter Property="Border.BorderThickness" Value="1" />
</Style>
</Style>
@@ -146,19 +151,45 @@
<Setter Property="ContentPresenter.IsVisible" Value="False" />
</Style>
<Style Selector="^ /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerCheckedDefaultBackground}" />
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerCheckedDefaultBackground}" />
</Style>
<Style Selector="^:pointerover /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerCheckedPointerOverBackground}" />
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerCheckedPointerOverBackground}" />
</Style>
<Style Selector="^:pressed /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerCheckedPressedBackground}" />
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerCheckedPressedBackground}" />
</Style>
<Style Selector="^:disabled /template/ Border#SwitchBackgroundBorder">
<Setter Property="Border.Background" Value="{DynamicResource ToggleSwitchContainerCheckedDisabledBackground}" />
<Setter Property="Border.Background"
Value="{DynamicResource ToggleSwitchContainerCheckedDisabledBackground}" />
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>
<ControlTheme x:Key="SimpleToggleSwitch" BasedOn="{StaticResource {x:Type ToggleSwitch}}" TargetType="ToggleSwitch">
<Setter Property="Template">
<ControlTemplate TargetType="ToggleSwitch">
<Grid
Background="Transparent"
Cursor="Hand"
ColumnDefinitions="Auto">
<Grid x:Name="PART_SwitchKnob" />
<Grid x:Name="PART_MovingKnobs" />
<ContentPresenter
x:Name="PART_OnContentPresenter"
Margin="{DynamicResource ToggleSwitchOnContentMargin}"
Content="{TemplateBinding OnContent}"
ContentTemplate="{TemplateBinding OnContentTemplate}" />
<ContentPresenter
x:Name="PART_OffContentPresenter"
Margin="{DynamicResource ToggleSwitchOnContentMargin}"
Content="{TemplateBinding OffContent}"
ContentTemplate="{TemplateBinding OffContentTemplate}" />
</Grid>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>