Xamarin - Reload Page after Navigation.PopModalAsync()

Viewed 5602

I am using Xamarin to create an app for both iOS and Android, I have a use case that I press a button and it will open a Modal, then after selecting a button on the modal, it will update some information and then I need to pop the Modal off and reload the main page under it. How is that possible?

Main Page:

public partial class MainPage : ContentPage
{
    public MainPage(Object obj)
    {

        InitializeComponent();

        // do some things with obj...

        BindingContext = this;

    }

    public ButtonPressed(object sender, EventArgs args)
    {
        Navigation.PushModalAsync(new SecondaryPage(newObj));
    }

}

Secondary Page:

public partial class SecondaryPage : ContentPage
{
    public SecondaryPage(Object newObj)
    {

        InitializeComponent();

        BindingContext = this;

    }

    public ButtonPressed(object sender, EventArgs args)
    {
        // Do something to change newObj

        Navigation.PopModalAsync();
    }

}

So after the PopModalAsync(), I need to be able to call the MainPage() constructor but pass it the "newObj" that I changed in the SecondaryPage. Is this even possible?

1 Answers
Related