[英]Xamarin MVVM update list from other Viewmodel
我在Xamarin Cross Platform android中工作,我有2个Viewmodels -MyTeamVM -CertificatesVM
MyTeamVm是一个列表视图,我可以在其中单击一个人。 单击后,我转到CertificatesVM,在其中我将看到被点击人员的证书。 问题是我第一次单击人员时一切正常,因为程序转到:(这是在certificateVM中)
protected override async Task InitializeAsync()
{
var user = _userDataService.GetSelectedUser();
Certificates = (await _earnedCertificateDataService.GetCertificateForUserAsync(user.Id));
}
但是,当我返回MyTeamView并选择另一个人时,他不会更新列表。 我有一个
public MvxCommand ReloadCertificates
{
get
{
return new MvxCommand(async () =>
{
var user = _userDataService.GetSelectedUser();
Certificates = (await _earnedCertificateDataService.GetCertificateForUserAsync(user.Id));
});
}
}
但它不起作用。
有人能帮助我吗?
您可以使用MessagingCenter调用其他viewModel列表
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/messaging-center/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.