我有两个视图:MainView
和ProfileView
。方法不会在ViewModel中调用 - MVVMCross
用户设置Age
属性在ProfileView
和以去MainView
经由Messaging
协议来更新Age
属性点击先前箭头按钮(PreviousDialog绑定)。
当用户单击上一个箭头按钮时,ProfileViewModel
中的以下实现不会调用NotifyUpdate
方法。我想知道我错过了什么或者错了什么?
ProfileViewModel.cs
public ICommand PreviousDialog
{
get
{
NotifyUpdate();
return new MvxCommand(() => ShowViewModel<MainViewModel>());
}
}
// the following method does not get called
private void NotifyUpdate()
{
var message = new CustomMessage(this, Age);
var messenger = Mvx.Resolve<IMvxMessenger>();
messenger.Publish(message);
}
Baiscally没错,你不需要为它做一个单独的方法。只需使用新的MvxCommand(()=> {NotifyUpdate(); ShowViewModel();}); –
Cyriac