

However, since aīoolean data type might be nullable, effectively allowing for a third option (true, false or null), the CheckBox control can also support this case. The IsThreeState propertyĪs mentioned, the CheckBox usually corresponds to a boolean value, which means that it only has two states: true or false (on or off). The appearance, and the cool thing is that no matter which part of the content you click on, it will activate the CheckBox and toggle it on or off. By specifying a control as the content, instead of just text, we get much more control of The text, and on the middle one I even throw in an Image control. On all three check boxes, I do something differently with You can use any type of control inside of it, as we'll see in the next example: Īs you can see from the sample markup, you can do pretty much whatever you want with the content. Piece of text, like I did in the example above, WPF will put it inside a TextBlock control and display it, but this is just a shortcut to make thingsĮasier for you. The CheckBox control inherits from the ContentControl class, which means that it can take custom content and display next to it.

The IsChecked property should also be used from Code-behind if you want to check whether a certain CheckBox is checked On the second CheckBox, I use the IsChecked property to have it checked by default, but other than that, Let's jump straight into anĮxample, in case you're not sure how a CheckBox looks: Īs you can see, the CheckBox is very easy to use. The CheckBox control allows the end-user to toggle an option on or off, usually reflecting a Boolean value in the Code-behind.
