我已将此属性数据绑定到一个按钮,如下所示,如何更新其他布尔属性以便再次检查时,如何通知按钮?
public bool AccountSelectedAndBankFileSelected
{
get
{
return SelectedAccount != null && SelectedAccount.BankFileSelected;
}
}
<Button Content="Open bank." IsEnabled="{Binding AccountSelectedAndBankFileSelected}" />
public bool BankFileSelected
{
get { return _bankFileSelected; }
set { _bankFileSelected = value; OnPropertyChanged("BankFileSelected"); }
}
答案 0 :(得分:2)
你有两个选择。您可以将AccountSelectedAndBankFileSelected
更改为依赖项属性,也可以实现INotifyPropertyChanged
接口。第二个可能是最简单的。你所做的就是实现这个界面。然后,当决定AccountSelectedAndBankFileSelected
结果的任何属性发生更改(因此SelectedAccount
和SelectedAccount.BankFileSelected
属性)时,会引发INotifyPropertyChanged
接口定义的事件。< / p>
答案 1 :(得分:1)
View
不知道该属性是否已更改。
您应该在RaisePropertyChanged("AccountSelectedAndBankFileSelected")
setter:
NotifyPropertyChanged("AccountSelectedAndBankFileSelected")
(或SelectedAccount.BankFileSelected
)
public bool BankFileSelected
{
get
{
return bankFileSelected;
}
set
{
bankFileSelected= value;
yourViewModel.RaisePropertyChanged("AccountSelectedAndBankFileSelected");
}
}