Beispiel #1
0
        public void NavigationStack_IsEmptyCollection()
        {
            NavigationState state = new NavigationState();

            Assert.IsNotNull(state.NavigationStack);
            Assert.AreEqual(0, state.NavigationStack.Count);
        }
Beispiel #2
0
        protected NavigationState StoreState()
        {
            // Create an object for storage of the navigation state

            NavigationState state = new NavigationState();

            // Enumerate all NavigationEntries in the navigation stack

            foreach (NavigationEntry entry in NavigationStack)
            {
                // Save the page state
                // TODO : Do this when navigating away from each page to save time when suspending

                SavePageState(entry);

                // Create an object for storage of this entry

                NavigationEntryState entryState = new NavigationEntryState(entry.PageName, entry.ArgumentsData, entry.StateData);
                state.NavigationStack.Add(entryState);
            }

            // Return the result

            return state;
        }
        protected void RestoreState(NavigationState state)
        {
            if (state == null)
                throw new ArgumentNullException(nameof(state));

            // Restore the navigation stack
            // NB: Flag that we are restoring state so we can pass a NavigationMode.Refresh to restored pages

            _restoringState = true;

            try
            {
                NavigationStack.Push(state.NavigationStack);
            }
            finally
            {
                _restoringState = false;
            }
        }
Beispiel #4
0
        protected void RestoreState(NavigationState state)
        {
            foreach (NavigationEntryState entryState in state.NavigationStack.Reverse())
            {
                // Push the restored navigation entry onto the stack

                NavigationStack.Push(new NavigationEntry(entryState.PageName, entryState.ArgumentsData, entryState.StateData));
            }

            // Display the last page in the stack

            DisplayNavigationEntry(CurrentPage);

            // Call NavigatedTo() on the restored page

            CallNavigatedTo(CurrentPage, NavigationMode.Refresh);
        }
        protected NavigationState StoreState()
        {
            // Create an object for storage of the navigation state

            NavigationState state = new NavigationState();

            // Enumerate all NavigationEntries in the navigation stack

            foreach (PageInfo pageInfo in NavigationStack)
            {
                // If the view model is IActivatable then use this to save the page state
                // NB: First check that the view has been created - this may still have state from a previous instance

                PageDetails pageDetails;

                if (_pageCache.TryGetValue(pageInfo, out pageDetails))
                {
                    object viewModel = pageDetails.ViewLifetimeContext.ViewModel;

                    if (viewModel is IActivatable)
                        ((IActivatable)viewModel).SaveState(pageInfo);
                }

                // Add to the navigation state

                state.NavigationStack.Add(pageInfo);
            }

            // Return the result

            return state;
        }