开发者

Modification required to transform a checkbox to a three-state one in WPF

开发者 https://www.devze.com 2023-03-16 19:53 出处:网络
I have a checkbox defined as follows: <CheckBox x:Name=\"T09_CH105\" IsChecked=\"{Binding Path=T09_CH105,Mode=TwoWay}\" Content=\"Others\"/>

I have a checkbox defined as follows:

<CheckBox x:Name="T09_CH105" IsChecked="{Binding Path=T09_CH105,Mode=TwoWay}" Content="Others"/>

And its corresponding DataMember:

[DataMember]
public Boolean T09_CH105 {
  get { return _T09_CH105; }
        set { if (_T09_CH105 != value) {
            _T09_CH105 = value;
            OnPropertyChanged("T09_CH105");
          }
      }
  }

How can I make it a three-state checkbox ? I haven't been able to figure out how to adapt what I've read online to my co开发者_如何学Pythonde.

Thanks


you should add the attribute:

IsThreeState="True"

to your XAML


Use a nullable bool: bool? or Nullable<bool> (see the corresponding msdn article for reference)

If the status is null the wpf checkbox displays a "half checked" state.

0

精彩评论

暂无评论...
验证码 换一张
取 消