WPF Web Based

WPF Examples

WPF

WPF Projects

WPF Project

adplus-dvertising
The CheckBox Control In WPF Web Base
Previous Home Next

CheckBox in the user interface (UI) of WPF application is used to represent options that a user can select or clear. You can use a single check box or you can group two or more check boxes so that users can choose any number of options from a list of options.

In XAML CheckBox tag represents the CheckBox Control.

 < CheckBox></ CheckBox>

Properties:

With the following tag I created the CheckBox, in which Height is height of the checkbox, Name is the nameof the checkbox. Background the the color of the box, Borderbrush is the color of the border, Forground is the color of the text.


<CheckBoxHeight="15"Margin="16,17,122,0"
Name="chkA2zdotnet"VerticalAlignment="Top"
Background="Cyan"BorderBrush="Blue"
Foreground="Chocolate"FlowDirection="LeftToRight"
HorizontalContentAlignment="Left"VerticalContentAlignment="Center">
A2ZDotnet.com</CheckBox>

  • 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.

Example:

XMAL Code.

<Page x:Class="WpfBrowserApplication2.chek"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="chek">
<Grid>
<StackPanel Background="BlueViolet" Height="104"
              VerticalAlignment="Top">
<CheckBox Name="cbxOne" IsChecked="False"
          Foreground="White" FontSize="16"
		  Checked="cbxOne_Checked">Check Box One</CheckBox>
<CheckBox Name="cbxTwo" IsChecked="True" 
Foreground="White" FontSize="16">Check Box Two</CheckBox>
<CheckBox Name="cbxThree" IsChecked="True" Foreground="White" 
          FontSize="16" >Check Box Three</CheckBox>
<CheckBox Name="cbxFour" IsChecked="True" Foreground="White" 
           FontSize="16" 
Checked="cbxFour_Checked">Check Box Four</CheckBox>
</StackPanel>
<Button HorizontalAlignment="Left" Margin="10,112,0,0"
          Name="button1" Width="75" Height="23" VerticalAlignment="Top"
          Click="button1_Click_1">Button</Button>
</Grid>
</Page>

XAML.CS CODE:


StringBuilder sb = new StringBuilder();
if (cbxOne.IsChecked == true)
    sb.AppendLine("Box One is Checked");
else
    sb.AppendLine("Box One is Unchecked");
if ((bool)cbxTwo.IsChecked)
    sb.AppendLine("Box Two is Checked");
else
    sb.AppendLine("Box Two is Unchecked");
if ((bool)cbxThree.IsChecked)
    sb.AppendLine("Box three is Checked");
else
    sb.AppendLine("Box Three is Unchecked");
if ((bool)cbxFour.IsChecked)
    sb.AppendLine("Box four is Checked");
else
    sb.AppendLine("Box four is Unchecked");
MessageBox.Show(sb.ToString(), "CheckBox");

Previous Home Next
WPF Examples

WPF

WPF

WPF

WPF

WPF

WPF

WPF

WPF