我有这个问题,我的复选框IsChecked属性绑定无法正常工作。我用谷歌搜索,但是人们说它应该支持双向绑定,这就是我正在使用的绑定。
这是我的代码:
<CheckBox Name="ckC" VerticalAlignment="Center"
IsChecked="{Binding Path=LSMChannelEnable[2],
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
这是其背后的C#代码:
public bool[] LSMChannelEnable
{
get
{
return this._liveImage.LSMChannelEnable;
}
set
{
this._liveImage.LSMChannelEnable = value;
OnPropertyChanged("LSMChannelEnable");
OnPropertyChanged("EnableChannelCount");
OnPropertyChanged("LSMChannel");
}
}
任何指针都受到高度赞赏,
这是因为您要绑定到数组。将要绑定到单独属性的属性拉出。
Xml:
IsChecked="{Binding Path=ButtonEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
码:
public bool ButtonEnabled
{
get { return this._liveImage.LSMChannelEnable[2]; }
set { this._liveImage.LSMChannelEnable[2] = value;
OnPropertyChanged("ButtonEnabled");
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句