AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Thursday 5 January 2017

How to create a custom style for checkbox in WPF?

In this article I am going to explain how to create a custom styling for wpf checkbox. We can modify the checkbox according to our custom requirement.  Please check below code for modifying the template & creating custom checkbox in WPF.

    <Style TargetType="{x:Type CheckBox}" x:Key="customCheckboxStyle">
        <Setter Property="Template">
                <ControlTemplate TargetType="{x:Type CheckBox}">
                    <StackPanel Orientation="Horizontal">
                        <Image x:Name="checkboxImage" Source="normal_image.png" Width="32"/>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="checkboxImage" Property="Source" Value="checked_image.png"/>
                                <Condition Property="IsMouseOver" Value="True"/>
                                <Condition Property="IsChecked" Value="False"/>
                            <Setter TargetName="checkboxImage" Property="Source" Value="hover_image.png"/>

   1 comment :

  1. how to get the Value="checked_image.png" through c# code?so that it can be changed dynamically


  • Popular Posts
  • Comments