This is a mirror of official site: http://jasper-net.blogspot.com/

#353 – Binding a Three-State CheckBox to a Nullable Bool

| Monday, August 1, 2011
Because a three-state CheckBox can take on any one of three different values, its current value can’t be represented by a simple bool.  A bool can only take on true and false values.

A three-state CheckBox can instead be bound to a nullable bool (represented by bool?), which can take on three different values.

    true  (checked)
    false  (not checked)
    null  (indeterminate)

In the example below, we bind a CheckBox control’s IsChecked property to a nullable bool property.

        <CheckBox Content="Happy" IsChecked="{Binding IsHappy}" IsThreeState="True"/>


Read more: 2,000 Things You Should Know About WPF
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://wpf.2000things.com/2011/07/29/353-binding-a-three-state-checkbox-to-a-nullable-bool/

Posted via email from Jasper-net

0 comments: