コード例 #1
0
        /// <summary>
        /// Call this method to save the navigation history along with session state locally. On failure, the Last Saved date is set to default (of the data type).
        /// </summary>
        /// <returns></returns>
        public static async Task SaveSessionState()
        {
            try
            {
                LastSessionSavedDate = default(DateTimeOffset);
                LastSessionOwner     = null;

                PageStates.Add((_currentPage as IManageable).SaveState());
                StorageFile navFile = await _folder.CreateFileAsync(NAV_FILE_NAME, CreationCollisionOption.ReplaceExisting);

                StorageFile stateFile = await _folder.CreateFileAsync(STATE_FILE_NAME, CreationCollisionOption.ReplaceExisting);

                bool result = true;
                result &= await StorageHelper.TryWriteAsync(navFile, RootFrame.GetNavigationState());

                result &= await StorageHelper.TryWriteAsync(stateFile, PageStates);

                if (result == true)
                {
                    LastSessionSavedDate = DateTimeOffset.UtcNow;
                    LastSessionOwner     = UserManager.CurrentUser.RegNo;
                }
            }
            catch { }
        }
コード例 #2
0
 /// <summary>
 /// Navigates to the desired page, passing a parameter to the next page.
 /// </summary>
 /// <param name="pageType">
 /// The type of page to navigate to.
 /// </param>
 /// <param name="parameter">
 /// The parameter to pass to the page being navigated to.
 /// </param>
 /// <param name="type">
 /// The type of navigation to use.
 /// </param>
 /// <remarks>
 /// This method calls SaveState() on the current page to store page specific state.
 /// </remarks>
 public static void NavigateTo(Type pageType, object parameter, NavigationType type)
 {
     _pageState = null;
     if (type == NavigationType.Default)
     {
         Dictionary <string, object> pageState = (_currentPage as IManageable).SaveState();
         RootFrame.Navigate(pageType, parameter);
         PageStates.Add(pageState);
     }
     else
     {
         RootFrame.Navigate(pageType, parameter);
         RootFrame.BackStack.Clear();
         PageStates.Clear();
     }
 }
コード例 #3
0
        /// <summary>
        /// Navigates to the desired page, passing a parameter to the next page.
        /// </summary>
        /// <param name="pageType">
        /// The type of page to navigate to.
        /// </param>
        /// <param name="parameter">
        /// The parameter to pass to the page being navigated to.
        /// </param>
        /// <param name="type">
        /// The type of navigation to use.
        /// </param>
        /// <remarks>
        /// This method calls SaveState() on the current page to store page specific state.
        /// </remarks>
        public static void NavigateTo(Type pageType, object parameter, NavigationType type)
        {
            _pageState   = null;
            _currentType = type;

            if (type == NavigationType.Default)
            {
                Dictionary <string, object> pageState = (_currentPage as IManageable).SaveState();
                RootFrame.Navigate(pageType, parameter);
                PageStates.Add(pageState);
            }
            else
            {
                ClearPageCache();
                RootFrame.Navigate(pageType, parameter);
                // Clearing of back stack and page states occur in Navigated event handler.
            }
        }