NavigationPage\NavigationPage.cs (52)
18 public static readonly BindableProperty BackButtonTitleProperty = BindableProperty.CreateAttached("BackButtonTitle", typeof(string), typeof(Page), null);
22 BindableProperty.CreateAttached("HasNavigationBar", typeof(bool), typeof(Page), true);
46 static readonly BindablePropertyKey CurrentPagePropertyKey = BindableProperty.CreateReadOnly(nameof(CurrentPage), typeof(Page), typeof(NavigationPage), null, propertyChanged: OnCurrentPageChanged);
51 static readonly BindablePropertyKey RootPagePropertyKey = BindableProperty.CreateReadOnly(nameof(RootPage), typeof(Page), typeof(NavigationPage), null);
72 public NavigationPage(Page root) : this(UseMauiHandler, root)
76 internal NavigationPage(bool setforMaui, Page root = null)
117 public Page Peek(int depth)
129 return (Page)InternalChildren[InternalChildren.Count - depth - 1];
132 IEnumerable<Page> INavigationPageController.Pages => InternalChildren.Cast<Page>();
140 public Page CurrentPage
142 get { return (Page)GetValue(CurrentPageProperty); }
147 public Page RootPage
149 get { return (Page)GetValue(RootPageProperty); }
158 if (bindable is Page page)
171 public static bool GetHasBackButton(Page page)
208 public Task<Page> PopAsync()
214 public async Task<Page> PopAsync(bool animated)
235 var result = await (this as INavigationPageController).PopAsyncInner(animated, false);
288 public Task PushAsync(Page page)
294 public async Task PushAsync(Page page, bool animated)
332 public static void SetHasBackButton(Page page, bool value)
377 void SendNavigated(Page previousPage, NavigationType navigationType)
383 void SendNavigating(Page navigatingFrom = null)
389 void FireDisappearing(Page page)
395 void FireAppearing(Page page)
467 CurrentPage = (Page)newStack[newStack.Count - 1];
468 RootPage = (Page)newStack[0];
513 if (oldValue is Page oldPage)
516 if (newValue is Page newPage && ((NavigationPage)bindable).HasAppeared)
587 var topLevelPage = parentPages[parentPages.Count - 1];
607 else if (toolbarRoot is Page p)
694 var visiblePage = Navigation.NavigationStack[NavigationStack.Count - 1];
723 readonly Lazy<ReadOnlyCastingList<Page, Element>> _castingList;
728 _castingList = new Lazy<ReadOnlyCastingList<Page, Element>>(() => new ReadOnlyCastingList<Page, Element>(Owner.InternalChildren));
733 protected override IReadOnlyList<Page> GetNavigationStack()
738 protected override void OnInsertPageBefore(Page page, Page before)
776 protected async override Task<Page> OnPopAsync(bool animated)
783 var currentPage = NavigationStack[NavigationStack.Count - 1];
784 var newCurrentPage = NavigationStack[NavigationStack.Count - 2];
816 Page previousPage = Owner.CurrentPage;
817 Page newPage = Owner.RootPage;
818 List<Page> pagesToRemove = new List<Page>();
826 var page = (Page)NavigationStack[lastIndex];
846 protected override Task OnPushAsync(Page root, bool animated)
851 var previousPage = Owner.CurrentPage;
871 protected override void OnRemovePage(Page page)
895 Owner.RootPage = (Page)Owner.InternalChildren[0];
NavigationPage\NavigationPage.Legacy.cs (31)
17 async Task<Page> PopAsyncInner(
26 var page = (Page)InternalChildren.Last();
27 var previousPage = CurrentPage;
29 var removedPage = await RemoveAsyncInner(page, animated, fast);
34 async Task<Page> RemoveAsyncInner(
35 Page page,
47 FireAppearing((Page)InternalChildren[NavigationPageController.StackDepth - 2]);
67 CurrentPage = (Page)InternalChildren.Last();
75 Task<Page> INavigationPageController.PopAsyncInner(bool animated, bool fast)
80 Task<Page> INavigationPageController.RemoveAsyncInner(Page page, bool animated, bool fast)
120 void InsertPageBefore(Page page, Page before)
152 var previousPage = CurrentPage;
155 FireAppearing((Page)InternalChildren[0]);
176 PoppedToRoot?.Invoke(this, new PoppedToRootEventArgs(RootPage, childrenToRemove.OfType<Page>().ToList()));
180 async Task PushAsyncInner(Page page, bool animated)
185 var previousPage = CurrentPage;
221 void PushPage(Page page)
231 void RemovePage(Page page)
253 RootPage = (Page)InternalChildren.First();
258 readonly Lazy<ReadOnlyCastingList<Page, Element>> _castingList;
263 _castingList = new Lazy<ReadOnlyCastingList<Page, Element>>(() => new ReadOnlyCastingList<Page, Element>(Owner.InternalChildren));
268 protected override IReadOnlyList<Page> GetNavigationStack()
273 protected override void OnInsertPageBefore(Page page, Page before)
278 protected override Task<Page> OnPopAsync(bool animated)
288 protected override Task OnPushAsync(Page root, bool animated)
293 protected override void OnRemovePage(Page page)
Page\Page.cs (27)
19 /// <remarks><see cref = "Page" /> is primarily a base class for more useful derived types. Objects that are derived from the <see cref="Page"/> class are most prominently used as the top level UI element in .NET MAUI applications. In addition to their role as the main pages of applications, <see cref="Page"/> objects and their descendants can be used with navigation classes, such as <see cref="NavigationPage"/> or <see cref="FlyoutPage"/>, among others, to provide rich user experiences that conform to the expected behaviors on each platform.
21 public partial class Page : VisualElement, ILayout, IPageController, IElementConfiguration<Page>, IPaddingElement, ISafeAreaView, ISafeAreaView2, IView, ITitledElement, IToolbarElement
50 internal static readonly BindableProperty IgnoresContainerAreaProperty = BindableProperty.Create(nameof(IgnoresContainerArea), typeof(bool), typeof(Page), false);
53 public static readonly BindableProperty BackgroundImageSourceProperty = BindableProperty.Create(nameof(BackgroundImageSource), typeof(ImageSource), typeof(Page), default(ImageSource));
56 public static readonly BindableProperty IsBusyProperty = BindableProperty.Create(nameof(IsBusy), typeof(bool), typeof(Page), false, propertyChanged: (bo, o, n) => ((Page)bo).OnPageBusyChanged());
62 public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(Page), null);
65 public static readonly BindableProperty IconImageSourceProperty = BindableProperty.Create(nameof(IconImageSource), typeof(ImageSource), typeof(Page), default(ImageSource));
67 readonly Lazy<PlatformConfigurationRegistry<Page>> _platformConfigurationRegistry;
81 /// Initializes a new instance of the <see cref="Page"/> class.
98 _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Page>>(() => new PlatformConfigurationRegistry<Page>(this));
437 var page = child as Page;
545 /// <exception cref="InvalidOperationException">Thrown when the page's <see cref="Element.RealParent"/> can't be casted to <see cref="Page"/> or <see cref="BaseShellItem"/>.</exception>
548 if (!Application.IsApplicationOrWindowOrNull(RealParent) && !(RealParent is Page) && !(RealParent is BaseShellItem))
610 var container = this as IPageContainer<Page>;
613 Page page = container.CurrentPage;
690 var pageContainer = this as IPageContainer<Page>;
713 var pageContainer = this as IPageContainer<Page>;
798 var container = this as IPageContainer<Page>;
820 public IPlatformElementConfiguration<T, Page> On<T>() where T : IConfigPlatform
866 (this as IPageContainer<Page>)?.CurrentPage?.SendNavigatedTo(args);
873 (this as IPageContainer<Page>)?.CurrentPage?.SendNavigatingFrom(args);
881 (this as IPageContainer<Page>)?.CurrentPage?.SendNavigatedFrom(args, false);
PlatformConfiguration\iOSSpecific\Page.cs (22)
6 using FormsElement = Maui.Controls.Page;
44 public static StatusBarHiddenMode PrefersStatusBarHidden(this IPlatformElementConfiguration<iOS, FormsElement> config)
55 public static IPlatformElementConfiguration<iOS, FormsElement> SetPrefersStatusBarHidden(this IPlatformElementConfiguration<iOS, FormsElement> config, StatusBarHiddenMode value)
97 public static UIStatusBarAnimation PreferredStatusBarUpdateAnimation(this IPlatformElementConfiguration<iOS, FormsElement> config)
108 public static IPlatformElementConfiguration<iOS, FormsElement> SetPreferredStatusBarUpdateAnimation(this IPlatformElementConfiguration<iOS, FormsElement> config, UIStatusBarAnimation value)
149 public static IPlatformElementConfiguration<iOS, FormsElement> SetUseSafeArea(this IPlatformElementConfiguration<iOS, FormsElement> config, bool value)
160 public static bool UsingSafeArea(this IPlatformElementConfiguration<iOS, FormsElement> config)
193 public static LargeTitleDisplayMode LargeTitleDisplay(this IPlatformElementConfiguration<iOS, FormsElement> config)
204 public static IPlatformElementConfiguration<iOS, FormsElement> SetLargeTitleDisplay(this IPlatformElementConfiguration<iOS, FormsElement> config, LargeTitleDisplayMode value)
237 public static Thickness SafeAreaInsets(this IPlatformElementConfiguration<iOS, FormsElement> config)
249 public static IPlatformElementConfiguration<iOS, FormsElement> SetSafeAreaInsets(this IPlatformElementConfiguration<iOS, FormsElement> config, Thickness value)
266 public static UIModalPresentationStyle ModalPresentationStyle(this IPlatformElementConfiguration<iOS, FormsElement> config)
277 public static IPlatformElementConfiguration<iOS, FormsElement> SetModalPresentationStyle(this IPlatformElementConfiguration<iOS, FormsElement> config, UIModalPresentationStyle value)
332 public static bool PrefersHomeIndicatorAutoHidden(this IPlatformElementConfiguration<iOS, FormsElement> config)
343 public static IPlatformElementConfiguration<iOS, FormsElement> SetPrefersHomeIndicatorAutoHidden(this IPlatformElementConfiguration<iOS, FormsElement> config, bool value)
PlatformConfiguration\WindowsSpecific\Page.cs (9)
10 using FormsElement = Maui.Controls.Page;
24 typeof(FormsElement), ToolbarPlacement.Default);
51 public static ToolbarPlacement GetToolbarPlacement(this IPlatformElementConfiguration<Windows, FormsElement> config)
62 public static IPlatformElementConfiguration<Windows, FormsElement> SetToolbarPlacement(
63 this IPlatformElementConfiguration<Windows, FormsElement> config, ToolbarPlacement value)
78 typeof(FormsElement), true);
105 public static bool GetToolbarDynamicOverflowEnabled(this IPlatformElementConfiguration<Windows, FormsElement> config)
116 public static IPlatformElementConfiguration<Windows, FormsElement> SetToolbarDynamicOverflowEnabled(
117 this IPlatformElementConfiguration<Windows, FormsElement> config, bool value)
Shell\Shell.cs (22)
29 public Page CurrentPage => GetVisiblePage() as Page;
75 ?? (bindable as Page)?.FindParentOfType<Shell>();
209 /// Sets the navigation animation that plays when a <see cref="Page"/> is navigated to with the <see cref = "GoToAsync(ShellNavigationState, bool)" /> method.
904 bool IShellController.ProposeNavigation(ShellNavigationSource source, ShellItem shellItem, ShellSection shellSection, ShellContent shellContent, IReadOnlyList<Page> stack, bool canCancel)
1153 Page _previousPage;
1532 if (GetVisiblePage() is Page page && page.SendBackButtonPressed())
1925 internal void SendPageAppearing(Page page)
1935 internal Page GetCurrentShellPage()
1938 Page currentPage = null;
2084 protected override IReadOnlyList<Page> GetNavigationStack() => SectionProxy?.NavigationStack;
2086 protected override void OnInsertPageBefore(Page page, Page before) => SectionProxy.InsertPageBefore(page, before);
2088 protected override Task<Page> OnPopAsync(bool animated) => SectionProxy.PopAsync(animated);
2092 protected override Task OnPushAsync(Page page, bool animated) => SectionProxy.PushAsync(page, animated);
2094 protected override void OnRemovePage(Page page) => SectionProxy.RemovePage(page);
2096 protected override async Task<Page> OnPopModal(bool animated)
2100 var page = _shell.CurrentPage;
2105 var modalPopped = await base.OnPopModal(animated);
2113 protected override async Task OnPushModal(Page modal, bool animated)
2148 protected override Task<Page> OnPopModal(bool animated) => _shellProxy.PopModalAsync(animated);
2150 protected override Task OnPushModal(Page modal, bool animated) => _shellProxy.PushModalAsync(modal, animated);
Shell\ShellSection.cs (62)
38 readonly List<(object Observer, Action<Page> Callback)> _displayedPageObservers =
39 new List<(object Observer, Action<Page> Callback)>();
52 Page IShellSectionController.PresentedPage
79 void IShellSectionController.AddDisplayedPageObserver(object observer, Action<Page> callback)
117 var page = _navStack[_navStack.Count - 1];
135 _navStack = new List<Page> { null };
157 var last = _navStack[_navStack.Count - 1];
168 void IShellSectionController.SendPopping(Page page)
179 void IShellSectionController.SendPopped(Page page)
211 Page _displayedPage;
212 List<Page> _navStack = new List<Page> { null };
255 public IReadOnlyList<Page> Stack => _navStack;
257 internal Page DisplayedPage
321 List<Page> navStack = null;
330 var navStackCopy = new List<Page>(_navStack);
351 List<Page> pagesToInsert = new List<Page>();
362 var page = GetOrCreateFromRoute(globalRoutes[i], queryData, services, i == globalRoutes.Count - 1, false);
393 Page navPage = navStack.Count > i + 1 ? navStack[i + 1] : null;
485 Page GetOrCreateFromRoute(string route, ShellRouteParameters queryData, IServiceProvider services, bool isLast, bool isPopping)
487 var content = Routing.GetOrCreateContent(route, services) as Page;
512 List<Page> modalPageStacks = new List<Page>();
513 List<Page> nonModalPageStacks = new List<Page>();
528 var content = GetOrCreateFromRoute(globalRoutes[i], queryData, services, isLast, false);
560 var modalPage = modalPageStacks[i];
589 Task PushModalAsync(Page page, bool isAnimated)
597 async Task PushStackOfPages(List<Page> pages, bool? animate)
634 protected virtual IReadOnlyList<Page> GetNavigationStack() => _navStack;
639 var previousPage = DisplayedPage;
726 protected virtual void OnInsertPageBefore(Page page, Page before)
758 protected async virtual Task<Page> OnPopAsync(bool animated)
763 List<Page> stack = _navStack.ToList();
777 var page = _navStack[_navStack.Count - 1];
816 var page = _navStack[_navStack.Count - 1];
824 _navStack = new List<Page> { null };
841 protected virtual Task OnPushAsync(Page page, bool animated)
843 List<Page> stack = _navStack.ToList();
873 internal async Task PopModalStackToPage(Page page, bool? animated)
881 var pageToPop = Navigation.ModalStack[Navigation.ModalStack.Count - 1];
906 protected virtual void OnRemovePage(Page page)
960 var presentedPage = sectionController.PresentedPage;
970 (sender as Page).ParentSet -= OnPresentedPageParentSet;
1007 void AddPage(Page page)
1012 void RemovePage(Page page)
1047 protected override IReadOnlyList<Page> GetNavigationStack() => _owner.GetNavigationStack();
1049 protected override async Task<Page> OnPopAsync(bool animated)
1062 var returnedPage = (_owner as IShellSectionController).PresentedPage;
1098 protected override Task OnPushAsync(Page page, bool animated)
1114 internal Task PushModalInnerAsync(Page modal, bool animated)
1121 internal Task<Page> PopModalInnerAsync(bool animated)
1126 protected override async Task OnPushModal(Page modal, bool animated)
1149 protected async override Task<Page> OnPopModal(bool animated)
1154 var page = ModalStack[ModalStack.Count - 1];
1159 protected override void OnRemovePage(Page page)
1184 protected override void OnInsertPageBefore(Page page, Page before)
1213 ShellNavigationState GetUpdatedStatus(IReadOnlyList<Page> stack)
Window\Window.cs (22)
23 nameof(Page), typeof(Page), typeof(Window), default(Page?),
25 propertyChanged: (b, o, n) => ((Window)b).OnPageChanged(o as Page, n as Page));
98 public Window(Page page)
114 public Page? Page
116 get => (Page?)GetValue(PageProperty);
438 internal void OnModalPopped(Page modalPage)
453 internal bool OnModalPopping(Page modalPage)
461 internal void OnModalPushed(Page modalPage)
474 internal void OnModalPushing(Page modalPage)
604 if (oldValue is Page oldPage)
608 void OnPageChanged(Page? oldPage, Page? newPage)
699 protected override void OnInsertPageBefore(Page page, Page before)
704 protected override Task OnPushAsync(Page page, bool animated)
709 protected override Task<Page> OnPopAsync(bool animated)
719 protected override void OnRemovePage(Page page)
724 protected override IReadOnlyList<Page> GetModalStack()
729 protected override Task<Page?> OnPopModal(bool animated)
734 protected override Task OnPushModal(Page modal, bool animated)