如何刷新导航上的一个但最后一个ContentPage [英] How to refresh the one but last ContentPage on the Navigation

查看:81
本文介绍了如何刷新导航上的一个但最后一个ContentPage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,使用它从NavigationStack弹出当前页面:

Typically, one pops the current page using this from the NavigationStack:

   Navigation.PopAsync( true );

如何使用Navigation重绘当前页面之前的页面?

How to I use Navigation to redraw the page just before the current page?

背景:当前页面更改了一些内容,需要重新显示在最后一页中.

Background: The current page changed something that need to get re-presented in the one but last page.

推荐答案

我假设您使用的数据模型不可观察/不可绑定,因此该页面不是自动更新的".

您可以使用MessagingCenter发布刷新事件",以避免将两个Page与事件耦合在一起.

You could use MessagingCenter to publish a "Refresh Event" to avoid coupling the two Pages with events...

在您的主页中:

MessagingCenter.Subscribe<MainPage> (this, "RefreshMainPage", (sender) => {
    // Call your main page refresh method
});

在第二页:

   MessagingCenter.Send<MainPage> (this, "RefreshMainPage");
   Navigation.PopAsync( true );

https://developer.xamarin.com/guides/xamarin-forms/messaging-center/

这篇关于如何刷新导航上的一个但最后一个ContentPage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆