CheckBoxStyle.xaml 9.45 KB
<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
	<ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="..\Colors\Colors.xaml"/>
	</ResourceDictionary.MergedDictionaries>
	<SolidColorBrush x:Key="CheckBoxFillNormal" Color="#F4F4F4"/>
	<!-- Resource dictionary entries should be defined here. -->
	<Style x:Key="EmptyCheckBoxFocusVisual">
		<Setter Property="Control.Template">
			<Setter.Value>
				<ControlTemplate>
					<Rectangle Margin="1" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<LinearGradientBrush x:Key="CheckBoxBackground" EndPoint="0.146,0.854" StartPoint="0.854,0.146">
		<GradientStop Color="#FFE7E7E7" Offset="0"/>
		<GradientStop Color="White" Offset="1"/>
	</LinearGradientBrush>
	<Style x:Key="CheckBoxStyle" TargetType="{x:Type CheckBox}">
		<Setter Property="Foreground" Value="{DynamicResource ForegroundNormalColorBrush}"/>
		<Setter Property="Background" Value="{DynamicResource CheckBoxBackground}"/>
		<Setter Property="BorderBrush" Value="{DynamicResource OuterBorderBrushStyle}"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="FocusVisualStyle" Value="{StaticResource EmptyCheckBoxFocusVisual}"/>
		<Setter Property="Template" Value="{DynamicResource CheckBoxControlTemplate}"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
	</Style>
	<ControlTemplate x:Key="CheckBoxControlTemplate" TargetType="{x:Type CheckBox}">
		<Grid Margin="{TemplateBinding Padding}">
			<Grid.RowDefinitions>
				<RowDefinition Height="7*"/>
				<RowDefinition Height="19*"/>
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="20"/>
				<ColumnDefinition Width="*"/>
			</Grid.ColumnDefinitions>
			<VisualStateManager.VisualStateGroups>
				<VisualStateGroup x:Name="CommonStates">
					<VisualState x:Name="Normal"/>
					<VisualState x:Name="MouseOver">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="MouseOverRectangle">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
					<VisualState x:Name="Pressed">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="MouseOverRectangle">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
							</ObjectAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="MouseOverRectangle">
								<EasingDoubleKeyFrame KeyTime="0" Value="0.9"/>
							</DoubleAnimationUsingKeyFrames>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="BaseRectangle">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
					<VisualState x:Name="Disabled">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="DisabledRectangle">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
				</VisualStateGroup>
				<VisualStateGroup x:Name="CheckStates">
					<VisualState x:Name="Checked">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="Tick">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
							</ObjectAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="InnerRectangle">
								<EasingDoubleKeyFrame KeyTime="0" Value="0.3"/>
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
					<VisualState x:Name="Unchecked"/>
					<VisualState x:Name="Indeterminate">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="InnerRectangle2">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
							</ObjectAnimationUsingKeyFrames>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="InnerRectangle1">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
							</ObjectAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Offset)" Storyboard.TargetName="InnerRectangle2">
								<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
							</DoubleAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="InnerRectangle2">
								<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
							</DoubleAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Offset)" Storyboard.TargetName="InnerRectangle2">
								<EasingDoubleKeyFrame KeyTime="0" Value="0.75"/>
							</DoubleAnimationUsingKeyFrames>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="InnerRectangle">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
				</VisualStateGroup>
			</VisualStateManager.VisualStateGroups>
			<Grid Grid.RowSpan="2">
				<Rectangle x:Name="BaseRectangle" Stroke="{TemplateBinding BorderBrush}" Width="14" Height="14" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{TemplateBinding Background}"/>
				<Rectangle x:Name="MouseOverRectangle" Stroke="{DynamicResource ButtonCheckingColorBrush}" Width="14" Height="14" HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="0.7" Visibility="Collapsed"/>
				<Grid SnapsToDevicePixels="True" Width="10" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center">
					<Rectangle x:Name="InnerRectangle" Stroke="{TemplateBinding BorderBrush}" Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="0.7"/>
					<Rectangle x:Name="InnerRectangle1" Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="1" Visibility="Collapsed" StrokeThickness="0">
						<Rectangle.Fill>
							<SolidColorBrush>#FFEB7F11</SolidColorBrush>
						</Rectangle.Fill>
					</Rectangle>
					<Rectangle x:Name="InnerRectangle2" Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Opacity="1" Visibility="Collapsed" Stroke="#99414141">
						<Rectangle.Fill>
							<LinearGradientBrush EndPoint="0.854,0.854" StartPoint="0.146,0.146">
								<GradientStop Color="#FFF4FF31"/>
								<GradientStop Color="#FFFF9800" Offset="0.6"/>
							</LinearGradientBrush>
						</Rectangle.Fill>
					</Rectangle>
					<Path x:Name="Tick" Data="M7.687375,0.2220739 C8.0155,-0.05973274 8.1038766,0.0097396618 8.29675,0.0029198407 8.5066265,-0.0045011927 9.1668963,0.57316282 9.29675,0.628 9.29675,0.628 9.562375,1.003 9.499875,1.206125 9.437375,1.40925 4.203,8.97175 4.203,8.97175 3.9929055,9.2410637 3.6989538,9.1618134 3.3908969,9.1598239 3.3908969,9.1598239 0.00027189102,5.8158239 0.00027189102,5.8158239 -0.0057670967,5.4862303 0.087374154,5.1787686 0.42202189,4.9251989 0.71874926,4.6074266 0.999875,4.3470739&#xD;&#xA;1.328,4.3314489 2.1634858,4.9882366 2.781125,5.7220739 3.593625,6.4408239 3.593625,6.4408239 7.687375,0.2220739 7.687375,0.2220739 z" HorizontalAlignment="Left" Stretch="None" StrokeThickness="0" Visibility="Collapsed" SnapsToDevicePixels="False" VerticalAlignment="Center" Height="9.172" Margin="0.297,0.372,0,0.456" Width="9.509" Opacity="1" Fill="{DynamicResource ButtonCheckingColorBrush3}"/>
				</Grid>
				<Rectangle x:Name="DisabledRectangle" Width="14" Height="14" HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="0.5" Visibility="Collapsed" Fill="{DynamicResource GrayLightBrush}"/>
			</Grid>
			<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Grid.Column="1" Margin="0,4.52,0,5.52" Grid.RowSpan="2"/>
		</Grid>
		<ControlTemplate.Triggers>
			<Trigger Property="HasContent" Value="True">
				<Setter Property="Padding" Value="4,0,0,0"/>
			</Trigger>
			<Trigger Property="IsEnabled" Value="False">
				<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>
</ResourceDictionary>