How to refresh the one but last ContentPage on the Navigation

前端 未结 3 1088
北海茫月
北海茫月 2020-12-19 13:37

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

   Navigation.PopAsync( true );

How to I use Naviga

3条回答
  •  余生分开走
    2020-12-19 14:32

    I'm assuming that the data model that you are using is not observable/bindable and thus the page is not "auto-updated"...

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

    In your MainPage:

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

    In your Second Page:

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

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

提交回复
热议问题