【发布时间】:2014-09-19 19:29:28
【问题描述】:
在调用 PopModalAsync 后仍使用模态页面的情况下,是否有解决 Android 未触发的解决方法。这是一个例子:
using System;
using Xamarin.Forms;
namespace XamarinForms
{
public class OnAppearingBug : ContentPage
{
Label label;
public OnAppearingBug ()
{
label = new Label {
Text = "Page"
};
Button button = new Button {
Text = "PushModal"
};
button.Clicked += (sender, e) => Navigation.PushModalAsync (new PopModalBug ());
Content = new StackLayout {
Children = { label, button }
};
}
protected override void OnAppearing(){
label.Text = "OnAppearing";
}
}
}
using System;
using Xamarin.Forms;
namespace XamarinForms
{
public class PopModalBug : ContentPage
{
public PopModalBug ()
{
Button button = new Button {
Text = "Pop Back"
};
//Bug: This will not trigger OnAppearing on Android
button.Clicked += (sender, e) => Navigation.PopModalAsync();
Content = new StackLayout {
Children = { button }
};
}
}
}
【问题讨论】:
-
我也面临同样的问题。 NavigationPage 文档的原因(有点类似于 Modal Push & Pop)
For each Xamarin.Forms.Page that you push or pop, the Android implementation of Xamarin.Forms.NavigationPage simply adds or removes the content of the page to or from a single activity.
标签: xamarin xamarin.android xamarin.forms