【问题标题】:Getting control after INavigation.PopAsync() in Xamarin Forms在 Xamarin Forms 中的 INavigation.PopAsync() 之后获取控制权
【发布时间】:2015-11-05 17:18:43
【问题描述】:

我有 PageA + ViewModelA 和 PageB + ViewModelB。

我从 A 调用 PushAsync(B),编辑一些数据,然后调用 PopAsync()。

所以现在 B 关闭,用户返回 A。

但是在 B 中,用户更改了一些状态,应该在 A 上更新。通知 A 更新状态的正确方法是什么(最好能够访问 ViewModelB)。

方法:

1. In B call PopAsync(), from NavigationStack get ViewModelA and manually trigger some update method
2. [doesn't work for me] In A call PushAsync(B) and wait until B becomes closed, so after that perform update with access to VMB (PushAsync doesn't lock A, so this approach doesn't work)

似乎这两种方法都不正确。

【问题讨论】:

    标签: xamarin xamarin-forms


    【解决方案1】:

    通常在 MVVM 环境中,当您需要向其他 ViewModel 发出“信号”更改时,您会使用消息传递系统。 根据 MVVM 框架,您需要查看对此可用的类。

    在 xamarin 表单中,您将拥有消息中心 https://developer.xamarin.com/guides/cross-platform/xamarin-forms/messaging-center/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多