[英]WPF checkbox IsChecked binding not working
I have this problem, that my checkbox IsChecked property binding is not working. 我有这个问题,我的复选框IsChecked属性绑定不起作用。 I googled, but people say it shoudl TwoWay binding which is what I am using.
我用谷歌搜索,但人们说它shoudl TwoWay绑定,这是我正在使用。
Here is my code: 这是我的代码:
<CheckBox Name="ckC" VerticalAlignment="Center"
IsChecked="{Binding Path=LSMChannelEnable[2],
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
Here is the C# code behind it: 这是它背后的C#代码:
public bool[] LSMChannelEnable
{
get
{
return this._liveImage.LSMChannelEnable;
}
set
{
this._liveImage.LSMChannelEnable = value;
OnPropertyChanged("LSMChannelEnable");
OnPropertyChanged("EnableChannelCount");
OnPropertyChanged("LSMChannel");
}
}
Any pointers are highly appreciated, 任何指针都非常感谢,
This is because you are binding to an array. 这是因为您绑定到数组。 Pull the property out that you want to bind to a separate property.
拉出要绑定到单独属性的属性。
Xaml: 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");
}
}
Try this: 尝试这个:
OnPropertyChanged("Item[]");
The property generated by the compiler when using an indexer. 编译器在使用索引器时生成的属性。 See this blog post .
看到这篇博文 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.