Share via


How to: Include an Image in a CheckBox

This example shows how to include an Image in a CheckBox. The example illustrates that a check box can contain content other than text.

Example

The following example creates a CheckBox that contains an Image and some text. When a user clicks the CheckBox, the text changes.

The example uses markup to create the CheckBox and code-behind to create the event handler.

<CheckBox Name="cb6" Checked="HandleChange1"><Image Source="data\flower.jpg" Height="30" Width="30"/>
</CheckBox>
private void HandleChange1(object sender, RoutedEventArgs e)
{
    txt.FontSize = 16;
    txt.Text = "I took this photo yesterday.";
}

For the complete sample, see CheckBox Sample.

See Also

Tasks

How to: Create a CheckBox
How to: Use Triggers to Style a CheckBox

Concepts

CheckBox Overview

Other Resources

CheckBox How-to Topics
CheckBox Samples