我有这个问题,我的复选框 IsChecked 属性绑定(bind)不起作用。我用谷歌搜索,但人们说它应该是我正在使用的 TwoWay 绑定(bind)。
这是我的代码:
<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");
}
}
非常感谢任何指点,
最佳答案
这是因为您绑定(bind)到一个数组。将要绑定(bind)到单独属性的属性拉出。
Xaml:
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");
}
}
关于c# - WPF 复选框 IsChecked 绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19459615/