#833 – CheckBox is a ContentControl
June 3, 2013 2 Comments
A CheckBox control derives from ContentControl, which means that it can contain a single piece of content. In the case of a CheckBox, this content is rendered next to the actual check box that a user can check on or off.
You typically set the content of a CheckBox to a string, which gets rendered next to the check box.
<CheckBox Content="Learn to juggle"/> <CheckBox Content="Read War and Peace"/> <CheckBox Content="Visit Japan"/>
You can, however, set the Content property to anything that you like, including a panel that contains other controls.
<CheckBox VerticalContentAlignment="Center"> <CheckBox.Content> <StackPanel> <Image Source="Juggler.png" Height="85"/> <Label Content="Learn to juggle"/> </StackPanel> </CheckBox.Content> </CheckBox> <CheckBox VerticalContentAlignment="Center"> <CheckBox.Content> <StackPanel> <Image Source="leo.jpg" Height="85"/> <Label Content="Read War and Peace"/> </StackPanel> </CheckBox.Content> </CheckBox> <CheckBox VerticalContentAlignment="Center"> <CheckBox.Content> <StackPanel> <Image Source="kinkakuji.jpg" Height="85"/> <Label Content="Visit Japan"/> </StackPanel> </CheckBox.Content> </CheckBox>
Pingback: Dew Drop – June 3, 2013 (#1,559) | Alvin Ashcraft's Morning Dew
Thanks the checkbox content is what i am looking for, your sample codes helped me, including my code snippet for other people’s reference: