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 (29)
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), propertyChanged: OnImageSourceChanged);
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));
442 var page = child as Page;
550 /// <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>
553 if (!Application.IsApplicationOrWindowOrNull(RealParent) && !(RealParent is Page) && !(RealParent is BaseShellItem))
615 var container = this as IPageContainer<Page>;
618 Page page = container.CurrentPage;
695 var pageContainer = this as IPageContainer<Page>;
718 var pageContainer = this as IPageContainer<Page>;
803 var container = this as IPageContainer<Page>;
825 public IPlatformElementConfiguration<T, Page> On<T>() where T : IConfigPlatform
871 (this as IPageContainer<Page>)?.CurrentPage?.SendNavigatedTo(args);
878 (this as IPageContainer<Page>)?.CurrentPage?.SendNavigatingFrom(args);
886 (this as IPageContainer<Page>)?.CurrentPage?.SendNavigatedFrom(args, false);
910 oldImageSource.SourceChanged -= ((Page)bindable).OnImageSourceSourceChanged;
913 newImageSource.SourceChanged += ((Page)bindable).OnImageSourceSourceChanged;
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)
31 public Page CurrentPage => GetVisiblePage() as Page;
77 ?? (bindable as Page)?.FindParentOfType<Shell>();
211 /// Sets the navigation animation that plays when a <see cref="Page"/> is navigated to with the <see cref = "GoToAsync(ShellNavigationState, bool)" /> method.
906 bool IShellController.ProposeNavigation(ShellNavigationSource source, ShellItem shellItem, ShellSection shellSection, ShellContent shellContent, IReadOnlyList<Page> stack, bool canCancel)
1155 Page _previousPage;
1534 if (GetVisiblePage() is Page page && page.SendBackButtonPressed())
1927 internal void SendPageAppearing(Page page)
1937 internal Page GetCurrentShellPage()
1940 Page currentPage = null;
2086 protected override IReadOnlyList<Page> GetNavigationStack() => SectionProxy?.NavigationStack;
2088 protected override void OnInsertPageBefore(Page page, Page before) => SectionProxy.InsertPageBefore(page, before);
2090 protected override Task<Page> OnPopAsync(bool animated) => SectionProxy.PopAsync(animated);
2094 protected override Task OnPushAsync(Page page, bool animated) => SectionProxy.PushAsync(page, animated);
2096 protected override void OnRemovePage(Page page) => SectionProxy.RemovePage(page);
2098 protected override async Task<Page> OnPopModal(bool animated)
2107 var modalPopped = await base.OnPopModal(animated);
2115 protected override async Task OnPushModal(Page modal, bool animated)
2150 protected override Task<Page> OnPopModal(bool animated) => _shellProxy.PopModalAsync(animated);
2152 protected override Task OnPushModal(Page modal, bool animated) => _shellProxy.PushModalAsync(modal, animated);
2163 public Page CurrentPage => shell.CurrentPage;
Shell\ShellSection.cs (63)
40 readonly List<(object Observer, Action<Page> Callback)> _displayedPageObservers =
41 new List<(object Observer, Action<Page> Callback)>();
54 Page IShellSectionController.PresentedPage
81 void IShellSectionController.AddDisplayedPageObserver(object observer, Action<Page> callback)
119 var page = _navStack[_navStack.Count - 1];
137 _navStack = new List<Page> { null };
159 var last = _navStack[_navStack.Count - 1];
170 void IShellSectionController.SendPopping(Page page)
181 void IShellSectionController.SendPopped(Page page)
213 Page _displayedPage;
214 List<Page> _navStack = new List<Page> { null };
257 public IReadOnlyList<Page> Stack => _navStack;
259 internal Page DisplayedPage
323 List<Page> navStack = null;
332 var navStackCopy = new List<Page>(_navStack);
353 List<Page> pagesToInsert = new List<Page>();
364 var page = GetOrCreateFromRoute(globalRoutes[i], queryData, services, i == globalRoutes.Count - 1, false);
395 Page navPage = navStack.Count > i + 1 ? navStack[i + 1] : null;
498 Page GetOrCreateFromRoute(string route, ShellRouteParameters queryData, IServiceProvider services, bool isLast, bool isPopping)
500 var content = Routing.GetOrCreateContent(route, services) as Page;
525 List<Page> modalPageStacks = new List<Page>();
526 List<Page> nonModalPageStacks = new List<Page>();
541 var content = GetOrCreateFromRoute(globalRoutes[i], queryData, services, isLast, false);
573 var modalPage = modalPageStacks[i];
602 Task PushModalAsync(Page page, bool isAnimated)
610 async Task PushStackOfPages(List<Page> pages, bool? animate)
647 protected virtual IReadOnlyList<Page> GetNavigationStack() => _navStack;
652 var previousPage = DisplayedPage;
739 protected virtual void OnInsertPageBefore(Page page, Page before)
771 protected async virtual Task<Page> OnPopAsync(bool animated)
776 List<Page> stack = _navStack.ToList();
790 var page = _navStack[_navStack.Count - 1];
829 var page = _navStack[_navStack.Count - 1];
837 _navStack = new List<Page> { null };
854 protected virtual Task OnPushAsync(Page page, bool animated)
856 List<Page> stack = _navStack.ToList();
886 internal async Task PopModalStackToPage(Page page, bool? animated)
894 var pageToPop = Navigation.ModalStack[Navigation.ModalStack.Count - 1];
919 protected virtual void OnRemovePage(Page page)
973 var presentedPage = sectionController.PresentedPage;
983 (sender as Page).ParentSet -= OnPresentedPageParentSet;
1020 void AddPage(Page page)
1025 void RemovePage(Page page)
1060 protected override IReadOnlyList<Page> GetNavigationStack() => _owner.GetNavigationStack();
1062 protected override async Task<Page> OnPopAsync(bool animated)
1075 var returnedPage = (_owner as IShellSectionController).PresentedPage;
1111 protected override Task OnPushAsync(Page page, bool animated)
1127 internal Task PushModalInnerAsync(Page modal, bool animated)
1134 internal Task<Page> PopModalInnerAsync(bool animated)
1139 protected override async Task OnPushModal(Page modal, bool animated)
1162 protected async override Task<Page> OnPopModal(bool animated)
1167 var page = ModalStack[ModalStack.Count - 1];
1172 protected override void OnRemovePage(Page page)
1197 protected override void OnInsertPageBefore(Page page, Page before)
1226 ShellNavigationState GetUpdatedStatus(IReadOnlyList<Page> stack)
1286 public IReadOnlyList<Page> Stack => section.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)