【发布时间】:2017-07-19 21:52:48
【问题描述】:
我正在使用 Xamarin 为 iOS 和 Android 创建一个应用程序,我有一个用例,我按下一个按钮,它将打开一个模态,然后在模态上选择一个按钮后,它会更新一些信息,然后我需要弹出模态并重新加载它下面的主页。这怎么可能?
主页:
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() 构造函数,但将我在 SecondaryPage 中更改的“newObj”传递给它。这甚至可能吗?
【问题讨论】:
-
要么将完成委托传递给您的模态,在它关闭时执行,要么使用 MessagingCenter 将消息从模态发送到主页
标签: android ios xamarin xamarin.forms navigation