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