Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The below code is a sample check box with three state.</p> <pre><code>&lt;Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"&gt; &lt;Window.Resources&gt; &lt;!-- Focus Style --&gt; &lt;SolidColorBrush x:Key="InputBackgroundFocused" Color="Orange"&gt;&lt;/SolidColorBrush&gt; &lt;Style x:Key="CheckBoxFocusVisualStyle"&gt; &lt;Setter Property="Control.Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate&gt; &lt;Border CornerRadius="2" Margin="0,0,4,3" BorderThickness="2" BorderBrush="{StaticResource InputBackgroundFocused}" Background="Transparent"/&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;!-- Fill Brushes --&gt; &lt;LinearGradientBrush x:Key="NormalBrush" StartPoint="0,0" EndPoint="0,1"&gt; &lt;GradientBrush.GradientStops&gt; &lt;GradientStopCollection&gt; &lt;GradientStop Color="#FFF" Offset="0.0"/&gt; &lt;GradientStop Color="#CCC" Offset="1.0"/&gt; &lt;/GradientStopCollection&gt; &lt;/GradientBrush.GradientStops&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="HorizontalNormalBrush" StartPoint="0,0" EndPoint="1,0"&gt; &lt;GradientBrush.GradientStops&gt; &lt;GradientStopCollection&gt; &lt;GradientStop Color="#FFF" Offset="0.0"/&gt; &lt;GradientStop Color="#CCC" Offset="1.0"/&gt; &lt;/GradientStopCollection&gt; &lt;/GradientBrush.GradientStops&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="LightBrush" StartPoint="0,0" EndPoint="0,1"&gt; &lt;GradientBrush.GradientStops&gt; &lt;GradientStopCollection&gt; &lt;GradientStop Color="#FFF" Offset="0.0"/&gt; &lt;GradientStop Color="#EEE" Offset="1.0"/&gt; &lt;/GradientStopCollection&gt; &lt;/GradientBrush.GradientStops&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="HorizontalLightBrush" StartPoint="0,0" EndPoint="1,0"&gt; &lt;GradientBrush.GradientStops&gt; &lt;GradientStopCollection&gt; &lt;GradientStop Color="#FFF" Offset="0.0"/&gt; &lt;GradientStop Color="#EEE" Offset="1.0"/&gt; &lt;/GradientStopCollection&gt; &lt;/GradientBrush.GradientStops&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="DarkBrush" StartPoint="0,0" EndPoint="0,1"&gt; &lt;GradientBrush.GradientStops&gt; &lt;GradientStopCollection&gt; &lt;GradientStop Color="#FFF" Offset="0.0"/&gt; &lt;GradientStop Color="#AAA" Offset="1.0"/&gt; &lt;/GradientStopCollection&gt; &lt;/GradientBrush.GradientStops&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="PressedBrush" StartPoint="0,0" EndPoint="0,1"&gt; &lt;GradientBrush.GradientStops&gt; &lt;GradientStopCollection&gt; &lt;GradientStop Color="#BBB" Offset="0.0"/&gt; &lt;GradientStop Color="#EEE" Offset="0.1"/&gt; &lt;GradientStop Color="#EEE" Offset="0.9"/&gt; &lt;GradientStop Color="#FFF" Offset="1.0"/&gt; &lt;/GradientStopCollection&gt; &lt;/GradientBrush.GradientStops&gt; &lt;/LinearGradientBrush&gt; &lt;SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" /&gt; &lt;SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" /&gt; &lt;SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FFF" /&gt; &lt;SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD" /&gt; &lt;!-- Border Brushes --&gt; &lt;LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1"&gt; &lt;GradientBrush.GradientStops&gt; &lt;GradientStopCollection&gt; &lt;GradientStop Color="#CCC" Offset="0.0"/&gt; &lt;GradientStop Color="#444" Offset="1.0"/&gt; &lt;/GradientStopCollection&gt; &lt;/GradientBrush.GradientStops&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="HorizontalNormalBorderBrush" StartPoint="0,0" EndPoint="1,0"&gt; &lt;GradientBrush.GradientStops&gt; &lt;GradientStopCollection&gt; &lt;GradientStop Color="#CCC" Offset="0.0"/&gt; &lt;GradientStop Color="#444" Offset="1.0"/&gt; &lt;/GradientStopCollection&gt; &lt;/GradientBrush.GradientStops&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="DefaultedBorderBrush" StartPoint="0,0" EndPoint="0,1"&gt; &lt;GradientBrush.GradientStops&gt; &lt;GradientStopCollection&gt; &lt;GradientStop Color="#777" Offset="0.0"/&gt; &lt;GradientStop Color="#000" Offset="1.0"/&gt; &lt;/GradientStopCollection&gt; &lt;/GradientBrush.GradientStops&gt; &lt;/LinearGradientBrush&gt; &lt;LinearGradientBrush x:Key="PressedBorderBrush" StartPoint="0,0" EndPoint="0,1"&gt; &lt;GradientBrush.GradientStops&gt; &lt;GradientStopCollection&gt; &lt;GradientStop Color="#444" Offset="0.0"/&gt; &lt;GradientStop Color="#888" Offset="1.0"/&gt; &lt;/GradientStopCollection&gt; &lt;/GradientBrush.GradientStops&gt; &lt;/LinearGradientBrush&gt; &lt;SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" /&gt; &lt;SolidColorBrush x:Key="SolidBorderBrush" Color="#888" /&gt; &lt;SolidColorBrush x:Key="LightBorderBrush" Color="#AAA" /&gt; &lt;!-- Miscellaneous Brushes --&gt; &lt;SolidColorBrush x:Key="GlyphBrush" Color="#444" /&gt; &lt;SolidColorBrush x:Key="LightColorBrush" Color="#DDD" /&gt; &lt;Style TargetType="{x:Type CheckBox}"&gt; &lt;Setter Property="SnapsToDevicePixels" Value="true"/&gt; &lt;Setter Property="OverridesDefaultStyle" Value="true"/&gt; &lt;Setter Property="FocusVisualStyle" Value="{DynamicResource CheckBoxFocusVisualStyle}" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="CheckBox"&gt; &lt;BulletDecorator Background="Transparent"&gt; &lt;BulletDecorator.Bullet&gt; &lt;Border x:Name="Border" Width="17" Height="17" CornerRadius="2" Background="{StaticResource NormalBrush}" BorderThickness="1" BorderBrush="{StaticResource NormalBorderBrush}"&gt; &lt;Path Width="11" Height="11" x:Name="CheckMark" SnapsToDevicePixels="False" Stroke="{StaticResource GlyphBrush}" StrokeThickness="2" Data="M 2,4 C 2,4 3,5 5,13 C 5,13 5,3 12,0" /&gt; &lt;/Border&gt; &lt;/BulletDecorator.Bullet&gt; &lt;ContentPresenter Margin="4,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" RecognizesAccessKey="True"/&gt; &lt;/BulletDecorator&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsChecked" Value="false"&gt; &lt;Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsChecked" Value="{x:Null}"&gt; &lt;Setter TargetName="CheckMark" Property="Data" Value="M 0 7 L 7 0" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsMouseOver" Value="true"&gt; &lt;Setter TargetName="Border" Property="Background" Value="{StaticResource DarkBrush}" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsPressed" Value="true"&gt; &lt;Setter TargetName="Border" Property="Background" Value="{StaticResource PressedBrush}" /&gt; &lt;Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource PressedBorderBrush}" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsEnabled" Value="false"&gt; &lt;Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}" /&gt; &lt;Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" /&gt; &lt;Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Window.Resources&gt; &lt;Grid&gt; &lt;StackPanel&gt; &lt;CheckBox&gt;Hello&lt;/CheckBox&gt; &lt;CheckBox IsThreeState="True"&gt;asdfsdaf&lt;/CheckBox&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; </code></pre> <p></p> <p>The best software to modify the existing look and feel of the controls is Expression Blend. If you want to change the existing look and feel and you have to modify the Control Template of the control. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload