在我的ViewModel中,我有一个Person对象的ObservableCollection(实现了INotifyPropertyChanged接口)和一个SelectedPerson属性。它们绑定到视图中的ListBox。此外,我的ViewModel还有以下Prism DelegateCommand:
什么是最优雅的方式,在
在
Private DelegateCommand _myCommand = New DelegateCommand(CanExecute)
Public DelegateCommand MyCommand {get {return _myCommand;}}
Private Bool CanExecute()
{
Return (SelectedPerson.Age > 40);
}
什么是最优雅的方式,在
SelectedPerson
更改和SelectedPerson
年龄更改时调用MyCommand.RaiseCanExecuteChanged?在
SelectedPerson
的setter中添加和删除属性更改处理程序似乎有点凌乱。