<CheckBox x:Class="Controls.CheckBoxEx_" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" Width="400" Height="400" d:DesignHeight="300" d:DesignWidth="300" > <CheckBox.Template> <ControlTemplate TargetType="{x:Type CheckBox}"> <Grid> <Image x:Name="Normal" Visibility="Visible" Source="{Binding NormalImp}" /> <Image x:Name="Pressed" Visibility="Hidden" Source="{Binding pressedImp}" /> <Image x:Name="MouseOver" Visibility="Hidden" Source="{Binding MouseOverImp}" /> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="Normal" Property="Visibility" Value="Hidden"/> <Setter TargetName="Pressed" Property="Visibility" Value="Hidden"/> <Setter TargetName="MouseOver" Property="Visibility" Value="Visible"/> </Trigger> <Trigger Property="IsChecked" Value="True"> <Setter TargetName="Normal" Property="Visibility" Value="Hidden"/> <Setter TargetName="Pressed" Property="Visibility" Value="Visible"/> <Setter TargetName="MouseOver" Property="Visibility" Value="Hidden"/> </Trigger> <Trigger Property="IsChecked" Value="False"> <Setter TargetName="Normal" Property="Visibility" Value="Visible"/> <Setter TargetName="Pressed" Property="Visibility" Value="Hidden"/> <Setter TargetName="MouseOver" Property="Visibility" Value="Hidden"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </CheckBox.Template> </CheckBox>
public partial class CheckBoxEx_ : CheckBox { public CheckBoxEx_() { InitializeComponent(); this.DataContext = this; } #region Field public Image mouseOver; public Image pressed; public Image normal; #endregion #region Properties public Image MouseOverImg { get { return mouseOver; } set { mouseOver = value; } } public Image PressedImg { get { return pressed; } set { pressed = value; } } public Image NormalImg { get { return normal; } set { normal = value; } } #endregion }