#852 – Setting a Three-State CheckBox to an Indeterminate Value

A three-state CheckBox can take on one of three values: true, false, or indeterminate.  You can use data binding to get/set the value of a three-state CheckBox, binding the control to a nullable bool.

You can also explicitly set the value of a CheckBox, in either XAML or code.

To set a CheckBox to an indeterminate value in code, just set its IsChecked property to null.

            chkPie.IsChecked = null;

852-001
To set a CheckBox to an indeterminate value in XAML, set its IsChecked property to {x:Null}.

        <CheckBox Name="chkPie" Content="I Like Pie" IsThreeState="True"
                  IsChecked="{x:Null}"/>
Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #852 – Setting a Three-State CheckBox to an Indeterminate Value

  1. Pingback: Dew Drop – June 28, 2013 (#1,375) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: