0
我使用Xamarin爲iOS和Android創建應用程序,我有一個用例,我按下一個按鈕,它將打開一個Modal,然後選擇一個按鈕後模式,它會更新一些信息,然後我需要彈出模態並重新加載它下面的主頁面。這怎麼可能?Xamarin - 在導航後重新載入頁面.PopModalAsync()
主頁:
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));
}
}
次頁面:
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();
}
}
打完PopModalAsync(),我需要能夠調用的MainPage()構造函數,但它傳遞了 「newObj」我在SecondaryPage中進行了更改。這甚至有可能嗎?
要麼通過在完成委託給你的模式,它關閉時執行,或使用MessagingCenter從發送消息模式到主頁面 – Jason