WPF IsChecked binding checkbox not working

I have this problem that my checkCheck IsChecked binding binding does not work. I googled, but people say this is shoudl TwoWay binding, which is what I use.

Here is my code:

<CheckBox Name="ckC" VerticalAlignment="Center" IsChecked="{Binding Path=LSMChannelEnable[2], Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> 

Below is the C # code:

  public bool[] LSMChannelEnable { get { return this._liveImage.LSMChannelEnable; } set { this._liveImage.LSMChannelEnable = value; OnPropertyChanged("LSMChannelEnable"); OnPropertyChanged("EnableChannelCount"); OnPropertyChanged("LSMChannel"); } } 

Any pointers are highly appreciated,

+6
source share
2 answers

This is because you are attached to an array. Pull the property that you want to bind to a single property.

Xaml:

 IsChecked="{Binding Path=ButtonEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 

code:

 public bool ButtonEnabled { get { return this._liveImage.LSMChannelEnable[2]; } set { this._liveImage.LSMChannelEnable[2] = value; OnPropertyChanged("ButtonEnabled"); } } 
+12
source

Try the following:

 OnPropertyChanged("Item[]"); 

The property generated by the compiler when using the indexer. See this blog post .

+4
source

Source: https://habr.com/ru/post/956291/


All Articles