Esempio n. 1
0
        /// <summary>
        /// Use this method to restore session state and navigation history. This method should only be called if Initialize() has already been executed./>
        /// </summary>
        /// <returns>
        /// True if app state was successfully restored.
        /// </returns>
        public static async Task <bool> TryRestoreState()
        {
            try
            {
                StorageFile navFile = await _folder.GetFileAsync(NAV_FILE_NAME);

                StorageFile stateFile = await _folder.GetFileAsync(STATE_FILE_NAME);

                PageStates = await StorageHelper.TryReadAsync <List <Dictionary <string, object> > >(stateFile, _standardKnownTypes);

                int topIndex = PageStates.Count - 1;
                _pageState = PageStates[topIndex];
                PageStates.RemoveAt(topIndex);

                string navHistory = await StorageHelper.TryReadAsync(navFile);

                RootFrame.SetNavigationState(navHistory);

                return(true);
            }
            catch
            {
                return(false);
            }
        }