public void HandleNavigated(ShellNavigatedEventArgs args)
        {
            if (AccumulateNavigatedEvents)
            {
                if (_accumulatedEvent == null)
                {
                    _accumulatedEvent = args;
                }
            }
            else
            {
                _accumulatedEvent = null;
                BaseShellItem baseShellItem = _shell.CurrentItem?.CurrentItem?.CurrentItem;

                if (baseShellItem != null)
                {
                    baseShellItem.OnAppearing(() =>
                    {
                        FireNavigatedEvents(args, _shell);
                    });
                }
                else
                {
                    FireNavigatedEvents(args, _shell);
                }

                void FireNavigatedEvents(ShellNavigatedEventArgs a, Shell shell)
                {
                    Navigated?.Invoke(this, args);
                    // reset active page route tree
                    Routing.ClearImplicitPageRoutes();
                    Routing.RegisterImplicitPageRoutes(_shell);
                }
            }
        }
Exemple #2
0
        public static BaseShellItem SearchForPart(this BaseShellItem part, Func <BaseShellItem, bool> searchBy)
        {
            if (searchBy(part))
            {
                return(part);
            }

            BaseShellItem baseShellItem = null;

            switch (part)
            {
            case IShellItemController item:
                foreach (var section in item.GetItems())
                {
                    baseShellItem = SearchForPart(section, searchBy);
                    if (baseShellItem != null)
                    {
                        return(baseShellItem);
                    }
                }
                break;

            case IShellSectionController section:
                foreach (var content in section.GetItems())
                {
                    baseShellItem = SearchForPart(content, searchBy);
                    if (baseShellItem != null)
                    {
                        return(baseShellItem);
                    }
                }
                break;
            }

            return(null);
        }
Exemple #3
0
 public static BaseShellItem SearchForRoute(this BaseShellItem shell, string route) =>
 SearchForPart(shell, (p) => p.Route == route);
Exemple #4
0
 public static T SearchForRoute <T>(this BaseShellItem shell, string route) where T : BaseShellItem =>
 (T)SearchForRoute(shell, route);
Exemple #5
0
        public void HandleNavigated(ShellNavigatedEventArgs args)
        {
            _waitingForWindow?.Dispose();
            _waitingForWindow = null;

            // we don't want to fire Navigated until shell is attached to an actual window
            if (_shell.Window == null || _shell.CurrentPage == null)
            {
                _shell.PropertyChanged += WaitForWindowToSet;
                var shellContent = _shell?.CurrentItem?.CurrentItem?.CurrentItem;

                if (shellContent != null)
                {
                    shellContent.ChildAdded += WaitForWindowToSet;
                }

                _waitingForWindow = new ActionDisposable(() =>
                {
                    _shell.PropertyChanged -= WaitForWindowToSet;
                    if (shellContent != null)
                    {
                        shellContent.ChildAdded -= WaitForWindowToSet;
                    }
                });

                void WaitForWindowToSet(object sender, EventArgs e)
                {
                    if (_shell.Window != null &&
                        _shell.CurrentPage != null)
                    {
                        _waitingForWindow?.Dispose();
                        _waitingForWindow = null;

                        _shell.CurrentItem?.SendAppearing();
                        HandleNavigated(args);
                    }
                }

                return;
            }

            if (AccumulateNavigatedEvents)
            {
                if (_accumulatedEvent == null)
                {
                    _accumulatedEvent = args;
                }
            }
            else
            {
                _accumulatedEvent = null;
                BaseShellItem baseShellItem = _shell.CurrentItem?.CurrentItem?.CurrentItem;

                if (baseShellItem != null)
                {
                    baseShellItem.OnAppearing(() =>
                    {
                        FireNavigatedEvents(args, _shell);
                    });
                }
                else
                {
                    FireNavigatedEvents(args, _shell);
                }

                void FireNavigatedEvents(ShellNavigatedEventArgs a, Shell shell)
                {
                    Navigated?.Invoke(this, args);
                    // reset active page route tree
                    Routing.ClearImplicitPageRoutes();
                    Routing.RegisterImplicitPageRoutes(_shell);
                }
            }
        }
        protected override bool IsShellElementVisible(BaseShellItem item)
        {
            IShellContentController controller = (IShellContentController)item;

            return(controller.Page == null || controller.Page.IsVisible);
        }