模型视图中的代码:
public Boolean EnableTextBox { get; set; }
public CustomerAccountVM()
{
this.EnableTextBox = false;
//...
}
视图中的代码: XAML:
<TextBox Text="{Binding Path=IdCustomer, Mode=Default}" IsEnabled="{Binding Path=EnableTextBox,Mode=Default}" />
为什么代码不起作用?
没有回答?
答案 0 :(得分:0)
您没有发布已启用属性已更新的事实。
您需要实施INotifyPropertyChanged
界面并将您的媒体资源更改为:
private Boolean _enableTextBox;
public Boolean EnableTextBox
{
get { return _enableTextBox; }
set
{
_enableTextBox = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
}
您应该将PropertyChanged
代码包装在一个方法中,这样您就不会重复自己了。