【发布时间】:2014-08-18 23:07:43
【问题描述】:
这段代码在我的类构造函数中:
CheckBox autoScrollCheckBox = new CheckBox();
autoScrollCheckBox.VerticalAlignment = VerticalAlignment.Center;
autoScrollCheckBox.Content = "Enable";
Binding autoScrollBinding = new Binding();
autoScrollBinding.Path = new PropertyPath("AutoScrollingIsEnabled");
autoScrollBinding.RelativeSource = new RelativeSource(RelativeSourceMode.Self);
autoScrollBinding.Mode = BindingMode.TwoWay;
autoScrollCheckBox.SetBinding(CheckBox.IsCheckedProperty, autoScrollBinding);
autoScrollBox.Content = autoScrollCheckBox;
这是同一类:
public bool AutoScrollingIsEnabled
{
get
{
return !autoScrollingIsPaused;
}
set
{
autoScrollingIsPaused = !value;
}
}
但永远不会调用 AutoScrollingIsEnabled。有什么问题?
【问题讨论】:
-
您是否正在实施 INotifyPropertyChanged?
-
我发现输出窗口对绑定问题非常有帮助。
标签: c# wpf data-binding checkbox binding