Files
Shrlalgo.RvKits/WPFluent/Controls/CheckBox/CheckBox.xaml

161 lines
10 KiB
XML

<!--
This Source Code Form is subject to the terms of the MIT License.
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
Copyright (C) Leszek Pomianowski and WPF UI Contributors.
All Rights Reserved.
Based on Microsoft XAML for Win UI
Copyright (c) Microsoft Corporation. All Rights Reserved.
-->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFluent.Controls"
xmlns:converters="clr-namespace:WPFluent.Converters"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!--
I don't see that CheckBox had combined states. Without it,
we cannot support both Themes and Intermediate states at the same time.
At the moment I think the themes are more important than IsThirdState.
Have to figure it out or make a new CheckBox control.
-->
<converters:FallbackBrushConverter x:Key="FallbackBrushConverter" />
<Color x:Key="FallbackColor">#FFFF0000</Color>
<Thickness x:Key="CheckBoxPadding">11,5,11,6</Thickness>
<Thickness x:Key="CheckBoxBorderThemeThickness">1</Thickness>
<Thickness x:Key="CheckBoxContentMargin">8,0,0,0</Thickness>
<system:Double x:Key="CheckBoxIconSize">14</system:Double>
<system:Double x:Key="CheckBoxHeight">22</system:Double>
<system:Double x:Key="CheckBoxWidth">22</system:Double>
<Style x:Key="DefaultCheckBoxStyle" TargetType="{x:Type CheckBox}">
<!-- Universal WPF UI focus -->
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<!-- Universal WPF UI focus -->
<Setter Property="Background" Value="{DynamicResource CheckBoxBackground}" />
<Setter Property="Foreground" Value="{DynamicResource CheckBoxForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource CheckBoxBorderBrush}" />
<Setter Property="BorderThickness" Value="{StaticResource CheckBoxBorderThemeThickness}" />
<Setter Property="Padding" Value="{StaticResource CheckBoxPadding}" />
<Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="KeyboardNavigation.IsTabStop" Value="True" />
<Setter Property="Focusable" Value="True" />
<Setter Property="MinWidth" Value="120" />
<Setter Property="MinHeight" Value="32" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<BulletDecorator
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Background="Transparent">
<BulletDecorator.Bullet>
<Border
x:Name="ControlBorderIconPresenter"
Width="{StaticResource CheckBoxHeight}"
Height="{StaticResource CheckBoxWidth}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding Border.CornerRadius}">
<Border
x:Name="StrokeBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}">
<Grid>
<controls:SymbolIcon
x:Name="ControlIcon"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="{StaticResource CheckBoxIconSize}"
FontWeight="Bold"
Foreground="{DynamicResource CheckBoxCheckGlyphForeground}"
Symbol="Checkmark48"
Visibility="Collapsed" />
</Grid>
</Border>
</Border>
</BulletDecorator.Bullet>
<ContentPresenter
x:Name="ContentPresenter"
Margin="{StaticResource CheckBoxContentMargin}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True" />
</BulletDecorator>
<ControlTemplate.Triggers>
<Trigger Property="Content" Value="{x:Null}">
<Setter TargetName="ContentPresenter" Property="Margin" Value="0" />
<Setter Property="MinWidth" Value="30" />
</Trigger>
<Trigger Property="Content" Value="">
<Setter TargetName="ContentPresenter" Property="Margin" Value="0" />
<Setter Property="MinWidth" Value="30" />
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}">
<Setter TargetName="ControlIcon" Property="Symbol" Value="Subtract16" />
<Setter TargetName="ControlIcon" Property="Visibility" Value="Visible" />
<Setter TargetName="ControlBorderIconPresenter" Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillChecked}" />
<Setter TargetName="StrokeBorder" Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBorderBrush}" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="ControlIcon" Property="Visibility" Value="Visible" />
<Setter TargetName="ControlBorderIconPresenter" Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillChecked}" />
<Setter TargetName="StrokeBorder" Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBorderBrush}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsChecked" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="StrokeBorder" Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedPointerOver}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsChecked" Value="{x:Null}" />
</MultiTrigger.Conditions>
<Setter TargetName="ControlBorderIconPresenter" Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedPointerOver}" />
<Setter TargetName="StrokeBorder" Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBorderBrush}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsChecked" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="ControlBorderIconPresenter" Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillCheckedPointerOver}" />
<Setter TargetName="StrokeBorder" Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBorderBrush}" />
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ControlBorderIconPresenter" Property="Background" Value="{DynamicResource CheckBoxCheckBackgroundFillUncheckedDisabled}" />
<Setter TargetName="StrokeBorder" Property="BorderBrush" Value="{DynamicResource CheckBoxCheckBackgroundStrokeUncheckedDisabled}" />
<Setter TargetName="ControlIcon" Property="Foreground" Value="{DynamicResource CheckBoxForegroundUncheckedDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource DefaultCheckBoxStyle}" TargetType="{x:Type CheckBox}" />
</ResourceDictionary>