WPF: Checkbox isChecked

This entry is part 17 of 54 in the series Learn WPF

How do we know if a checkbox is checked, you may ask.

The WPF checkbox comes with a IsChecked boolean where we can use it to determine if a checkbox is checked or unchecked.

In the example below, we set the checkbox using IsChecked=’True”.

<Window x:Class="CheckBox1.MainWindow"
        Title="MainWindow" Height="350" Width="525">

        <Grid Name="grid1">
            <CheckBox Name="cb" IsChecked="True" Margin="50" HorizontalAlignment="left" FontSize="24" >Check Box</CheckBox>
        <TextBlock Name="tB" Text="Check Box Status" HorizontalAlignment="right" Margin="50"></TextBlock>

using System.Windows;
using System.Windows.Controls;

namespace CheckBox1
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
        public MainWindow()

            if (cb.IsChecked==true)
                tB.Text = "Checkbox is checked";

The output from running the above code is:



Series Navigation<< WPF: XAML checkbox
WPF: object sender >>

Leave a comment

Leave a Reply