Eurofurence.Companion.Common.NavigationHelper.OnNavigatedTo C# (CSharp) Method

OnNavigatedTo() public method

Invoked when this page is about to be displayed in a Frame. This method calls LoadState, where all page specific navigation and process lifetime management logic should be placed.
public OnNavigatedTo ( NavigationEventArgs e ) : void
e NavigationEventArgs Event data that describes how this page was reached. The Parameter /// property provides the group to be displayed.
return void
        public void OnNavigatedTo(NavigationEventArgs e)
        {
            var frameState = SuspensionManager.SessionStateForFrame(Frame);
            _pageKey = "Page-" + Frame.BackStackDepth;

            if (e.NavigationMode == NavigationMode.New)
            {
                // Clear existing state for forward navigation when adding a new page to the
                // navigation stack
                var nextPageKey = _pageKey;
                int nextPageIndex = Frame.BackStackDepth;
                while (frameState.Remove(nextPageKey))
                {
                    nextPageIndex++;
                    nextPageKey = "Page-" + nextPageIndex;
                }

                // Pass the navigation parameter to the new page
                LoadState?.Invoke(this, new LoadStateEventArgs(e.Parameter, null));
            }
            else
            {
                // Pass the navigation parameter and preserved page state to the page, using
                // the same strategy for loading suspended state and recreating pages discarded
                // from cache
                LoadState?.Invoke(this, new LoadStateEventArgs(e.Parameter, (Dictionary<string, object>)frameState[_pageKey]));
            }
        }