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)
464 CurrentPage = (Page)newStack[newStack.Count - 1];
465 RootPage = (Page)newStack[0];
510 if (oldValue is Page oldPage)
513 if (newValue is Page newPage && ((NavigationPage)bindable).HasAppeared)
584 var topLevelPage = parentPages[parentPages.Count - 1];
604 else if (toolbarRoot is Page p)
691 var visiblePage = Navigation.NavigationStack[NavigationStack.Count - 1];
720 readonly Lazy<ReadOnlyCastingList<Page, Element>> _castingList;
725 _castingList = new Lazy<ReadOnlyCastingList<Page, Element>>(() => new ReadOnlyCastingList<Page, Element>(Owner.InternalChildren));
730 protected override IReadOnlyList<Page> GetNavigationStack()
735 protected override void OnInsertPageBefore(Page page, Page before)
773 protected async override Task<Page> OnPopAsync(bool animated)
780 var currentPage = NavigationStack[NavigationStack.Count - 1];
781 var newCurrentPage = NavigationStack[NavigationStack.Count - 2];
813 Page previousPage = Owner.CurrentPage;
814 Page newPage = Owner.RootPage;
815 List<Page> pagesToRemove = new List<Page>();
823 var page = (Page)NavigationStack[lastIndex];
843 protected override Task OnPushAsync(Page root, bool animated)
848 var previousPage = Owner.CurrentPage;
868 protected override void OnRemovePage(Page page)
892 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)
21 /// <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.
24 public partial class Page : VisualElement, ILayout, IPageController, IElementConfiguration<Page>, IPaddingElement, ISafeAreaView, ISafeAreaView2, IView, ITitledElement, IToolbarElement
53 internal static readonly BindableProperty IgnoresContainerAreaProperty = BindableProperty.Create(nameof(IgnoresContainerArea), typeof(bool), typeof(Page), false);
56 public static readonly BindableProperty BackgroundImageSourceProperty = BindableProperty.Create(nameof(BackgroundImageSource), typeof(ImageSource), typeof(Page), default(ImageSource));
59 public static readonly BindableProperty IsBusyProperty = BindableProperty.Create(nameof(IsBusy), typeof(bool), typeof(Page), false, propertyChanged: (bo, o, n) => ((Page)bo).OnPageBusyChanged());
65 public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(Page), null);
68 public static readonly BindableProperty IconImageSourceProperty = BindableProperty.Create(nameof(IconImageSource), typeof(ImageSource), typeof(Page), default(ImageSource));
70 readonly Lazy<PlatformConfigurationRegistry<Page>> _platformConfigurationRegistry;
84 /// Initializes a new instance of the <see cref="Page"/> class.
101 _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Page>>(() => new PlatformConfigurationRegistry<Page>(this));
440 var page = child as Page;
548 /// <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>
551 if (!Application.IsApplicationOrWindowOrNull(RealParent) && !(RealParent is Page) && !(RealParent is BaseShellItem))
613 var container = this as IPageContainer<Page>;
616 Page page = container.CurrentPage;
693 var pageContainer = this as IPageContainer<Page>;
716 var pageContainer = this as IPageContainer<Page>;
801 var container = this as IPageContainer<Page>;
823 public IPlatformElementConfiguration<T, Page> On<T>() where T : IConfigPlatform
869 (this as IPageContainer<Page>)?.CurrentPage?.SendNavigatedTo(args);
876 (this as IPageContainer<Page>)?.CurrentPage?.SendNavigatingFrom(args);
884 (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;
496 Page GetOrCreateFromRoute(string route, ShellRouteParameters queryData, IServiceProvider services, bool isLast, bool isPopping)
498 var content = Routing.GetOrCreateContent(route, services) as Page;
523 List<Page> modalPageStacks = new List<Page>();
524 List<Page> nonModalPageStacks = new List<Page>();
539 var content = GetOrCreateFromRoute(globalRoutes[i], queryData, services, isLast, false);
571 var modalPage = modalPageStacks[i];
600 Task PushModalAsync(Page page, bool isAnimated)
608 async Task PushStackOfPages(List<Page> pages, bool? animate)
645 protected virtual IReadOnlyList<Page> GetNavigationStack() => _navStack;
650 var previousPage = DisplayedPage;
737 protected virtual void OnInsertPageBefore(Page page, Page before)
769 protected async virtual Task<Page> OnPopAsync(bool animated)
774 List<Page> stack = _navStack.ToList();
788 var page = _navStack[_navStack.Count - 1];
827 var page = _navStack[_navStack.Count - 1];
835 _navStack = new List<Page> { null };
852 protected virtual Task OnPushAsync(Page page, bool animated)
854 List<Page> stack = _navStack.ToList();
884 internal async Task PopModalStackToPage(Page page, bool? animated)
892 var pageToPop = Navigation.ModalStack[Navigation.ModalStack.Count - 1];
917 protected virtual void OnRemovePage(Page page)
971 var presentedPage = sectionController.PresentedPage;
981 (sender as Page).ParentSet -= OnPresentedPageParentSet;
1018 void AddPage(Page page)
1023 void RemovePage(Page page)
1058 protected override IReadOnlyList<Page> GetNavigationStack() => _owner.GetNavigationStack();
1060 protected override async Task<Page> OnPopAsync(bool animated)
1073 var returnedPage = (_owner as IShellSectionController).PresentedPage;
1109 protected override Task OnPushAsync(Page page, bool animated)
1125 internal Task PushModalInnerAsync(Page modal, bool animated)
1132 internal Task<Page> PopModalInnerAsync(bool animated)
1137 protected override async Task OnPushModal(Page modal, bool animated)
1160 protected async override Task<Page> OnPopModal(bool animated)
1165 var page = ModalStack[ModalStack.Count - 1];
1170 protected override void OnRemovePage(Page page)
1195 protected override void OnInsertPageBefore(Page page, Page before)
1224 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);
439 internal void OnModalPopped(Page modalPage)
454 internal bool OnModalPopping(Page modalPage)
462 internal void OnModalPushed(Page modalPage)
475 internal void OnModalPushing(Page modalPage)
605 if (oldValue is Page oldPage)
609 void OnPageChanged(Page? oldPage, Page? newPage)
700 protected override void OnInsertPageBefore(Page page, Page before)
705 protected override Task OnPushAsync(Page page, bool animated)
710 protected override Task<Page> OnPopAsync(bool animated)
720 protected override void OnRemovePage(Page page)
725 protected override IReadOnlyList<Page> GetModalStack()
730 protected override Task<Page?> OnPopModal(bool animated)
735 protected override Task OnPushModal(Page modal, bool animated)