예제 #1
0
        void OnAppearing(object sender, EventArgs e)
        {
            // Update the Container level Toolbar with my Toolbar information
            if (FindMyToolbar() is not NavigationPageToolbar)
            {
                // If the root is a flyoutpage then we set the toolbar on the flyout page
                var flyoutPage = this.FindParentOfType <FlyoutPage>();
                if (flyoutPage != null && flyoutPage.Parent is IWindow)
                {
                    var toolbar = new NavigationPageToolbar(flyoutPage, flyoutPage);
                    flyoutPage.Toolbar = toolbar;
                }
                // Is the root a modal page?
                else
                {
                    // Is the root the window or is this part of a modal stack
                    var rootPage = this.FindParentWith(x => (x is IWindow te || Navigation.ModalStack.Contains(x)), true);

                    if (rootPage is Window w)
                    {
                        var toolbar = new NavigationPageToolbar(w, w.Page);
                        w.Toolbar = toolbar;
                    }
                    else if (rootPage is Page p)
                    {
                        var toolbar = new NavigationPageToolbar(p, p);
                        p.Toolbar = toolbar;
                    }
                }
            }
        }
예제 #2
0
        void OnAppearing(object sender, EventArgs e)
        {
            // Update the Container level Toolbar with my Toolbar information
            if (FindMyToolbar() is NavigationPageToolbar ct)
            {
                ct.ApplyNavigationPage(this, HasAppeared);
            }
            // This means the toolbar hasn't been initialized yet
            // This code figures out what level the toolbar gets set on
            else
            {
                // If the root is a flyoutpage then we set the toolbar on the flyout page
                var flyoutPage = this.FindParentOfType <FlyoutPage>();
                if (flyoutPage != null && flyoutPage.Parent is IWindow)
                {
                    var toolbar = new NavigationPageToolbar(flyoutPage);
                    toolbar.ApplyNavigationPage(this, true);
                    flyoutPage.Toolbar = toolbar;
                }
                // Is the root a modal page?
                else
                {
                    // Is the root the window or is this part of a modal stack
                    var rootPage = this.FindParentWith(x => (x is IWindow te || Navigation.ModalStack.Contains(x)), true);

                    if (rootPage is Window w)
                    {
                        var toolbar = new NavigationPageToolbar(w);
                        toolbar.ApplyNavigationPage(this, true);
                        w.Toolbar = toolbar;
                    }
                    else if (rootPage is Page p)
                    {
                        var toolbar = new NavigationPageToolbar(p);
                        toolbar.ApplyNavigationPage(this, true);
                        p.Toolbar = toolbar;
                    }
                }
            }
        }