}),
2, 14);
+ grid.Children.Add(MakeButton("Show Alert",
+ async () => {
+ var result = await DisplayAlert("Title", "Message", "Ok", "Cancel");
+ Console.WriteLine($"Alert result: {result}");
+ }), 0, 15);
+
Content = new ScrollView { Content = grid };
--- /dev/null
+using System.ComponentModel;
+
+namespace Xamarin.Forms.Internals
+{
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static class PageExtensions
+ {
+ public static Page AncestorToRoot(this Page page)
+ {
+ Element parent = page;
+ while (!Application.IsApplicationOrNull(parent.RealParent))
+ parent = parent.RealParent;
+
+ return parent as Page;
+ }
+ }
+}
public Page Pop(Page ancestralNav)
{
- ancestralNav = AncestorToRoot(ancestralNav);
+ ancestralNav = ancestralNav.AncestorToRoot();
foreach (List<Page> stack in _navTree)
{
if (stack.Contains(ancestralNav))
public void PopToRoot(Page ancestralNav)
{
- ancestralNav = AncestorToRoot(ancestralNav);
+ ancestralNav = ancestralNav.AncestorToRoot();
foreach (List<Page> stack in _navTree)
{
if (stack.Contains(ancestralNav))
return;
}
- ancestralNav = AncestorToRoot(ancestralNav);
+ ancestralNav = ancestralNav.AncestorToRoot();
foreach (List<Page> stack in _navTree)
{
return found;
}
-
- Page AncestorToRoot(Page ancestor)
- {
- Page result = ancestor;
- while (!Application.IsApplicationOrNull(result.RealParent))
- result = (Page)result.RealParent;
- return result;
- }
}
}
\ No newline at end of file
bool PageIsChildOfPlatform(Page page)
{
- while (!Application.IsApplicationOrNull(page.RealParent))
- page = (Page)page.RealParent;
-
- return Page == page || _navModel.Roots.Contains(page);
+ var parent = page.AncestorToRoot();
+ return Page == parent || _navModel.Roots.Contains(parent);
}
SizeRequest IPlatform.GetNativeSize(VisualElement view, double widthConstraint, double heightConstraint)
bool PageIsChildOfPlatform(Page page)
{
- while (!Application.IsApplicationOrNull(page.RealParent))
- page = (Page)page.RealParent;
-
- return Page == page || _modals.Contains(page);
+ var parent = page.AncestorToRoot();
+ return Page == parent || _modals.Contains(parent);
}
// Creates a UIAlertAction which includes a call to hide the presenting UIWindow at the end