0
所有,MVVM - ICommand的和INotifyPropertyChanged的查詢
剛開始瓦特/ MVVM ......得到了交談ABT MVVM幾篇文章......我有兩個疑問..
始終INotifyPropertyChanged的和的ICommand執行會是這樣嗎?還是需要其他更改?
如果我點擊某個按鈕,需要調用一些模型的方法?我怎樣才能達到目的?
THX提前..
這家酒店實現@模型
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
的ICommand - 這是實現@ VM
private ICommand mUpdater;
public ICommand UpdateCommand
{
get
{
if (mUpdater == null)
mUpdater = new Updater();
return mUpdater;
}
set
{
mUpdater = value;
}
}
private class Updater : ICommand
{
#region ICommand Members
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
}
#endregion
}