CheckBox Control In WPF
The Content attribute represents the text of a CheckBox.
The Name attribute represents the name of the control, which is a unique identifier of a control.
The Foreground attribute defines the foreground color of the text of the CheckBox.
The Content attribute defines the text of the CheckBox.
FontFamily, FontStyle, FontWeight, FontSize and FontStretch are font related attribute
The IsChecked property represents the state of the CheckBox control. The IsThreeState property represents whether the CheckBox has two or three states. Three states are checked, unchecked, or indeterminate.
Code for CheckBox Control is given Below-
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="396.25" Width="453.75">
<Grid>
<CheckBox Name="McCheckBox" Foreground="Orange"
Canvas.Left="20" Canvas.Top="10" Content="Check Me"
FontFamily="Georgia" FontSize="20" FontWeight="Bold">
</CheckBox>
</Grid>
</Window>
Output
Adding Events on CheckBox
The Checked and Unchecked attributes of the CheckBox element adds the checked and unchecked event handler. These events are fired when a CheckBox state is changed to checked and unchecked respectively.
<CheckBox Name="McCheckBox"
Canvas.Left="10" Canvas.Top="10"
Content="Check Me"
IsChecked="True" IsThreeState="True"
Checked="McCheckBox_Checked"
Unchecked="McCheckBox_Unchecked">
</CheckBox>
Output
No comments:
Post a Comment