Share via


How to: Create a CheckBox

This example creates a CheckBox control.

Example

The following example creates a CheckBox control by using markup to create the check box and code-behind to handle the Click event.

When a user selects the CheckBox, the text changes.

<CheckBox Margin="10, 10, 3, 3" Grid.Column="0" Grid.Row="2" Name="cb1" FontSize="12" 
Checked="HandleChange">Check Box</CheckBox>
private void HandleChange(object sender, RoutedEventArgs e)
{
    cb1.Content = "You clicked the check box";
}

For the complete sample, see CheckBox Sample.

See Also

Tasks

How to: Include an Image in a CheckBox

Concepts

CheckBox Overview

Other Resources

CheckBox How-to Topics
CheckBox Samples