本文整理汇总了C#中Windows.UI.Xaml.Controls.Frame.GetNavigationState方法的典型用法代码示例。如果您正苦于以下问题:C# Frame.GetNavigationState方法的具体用法?C# Frame.GetNavigationState怎么用?C# Frame.GetNavigationState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.Frame
的用法示例。
在下文中一共展示了Frame.GetNavigationState方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveFrameNavigationState
private static void SaveFrameNavigationState(Frame frame)
{
var frameState = SessionStateForFrame(frame);
frameState["Navigation"] = frame.GetNavigationState();
}
示例2: SaveFrameNavigationState
private void SaveFrameNavigationState(Frame frame)
{
var stateDictionary = new Dictionary<string, object>();
// It is not at all suspected, but by design frame.GetNavigationState() will call OnNavigatedFrom on the current page
stateDictionary.Add("NavigationState", frame.GetNavigationState());
_sessionState["Navigation"] = stateDictionary;
}
示例3: SaveFrameNavigationState
private static void SaveFrameNavigationState(Frame frame)
{
var frameState = SessionStateForFrame(frame);
// TODO: exception이 발생한다.
try
{
frameState["Navigation"] = frame.GetNavigationState();
}
catch (Exception)
{
// do nothing.
}
}
示例4: SaveFrameNavigationState
private static void SaveFrameNavigationState(Frame frame) {
Dictionary<string, object> frameState = SessionStateForFrame(frame);
frameState["Navigation"] = frame.GetNavigationState();
}
示例5: Navigate
/// <summary>
/// Attempts to navigate to a specific page, loading from suspension settings if requested.
/// </summary>
/// <param name="pageType">The type of the page.</param>
/// <param name="parameter">The parameter to pass to the page.</param>
/// <param name="previousState">The previous execution state of the application. If the previous state was ApplicationExecutionState.Terminated, then the method will attempt to load suspension settings. </param>
/// <param name="forceReplaceCurrent">Determines whether the current page is replaced never, always, or only if it is different.</param>
/// <param name="clearHistory">Clears the history stack up to this point. Use this option if navigating to a page without a back button.</param>
/// <returns>A Task object for async operations.</returns>
public async System.Threading.Tasks.Task Navigate(Type pageType, object parameter, ApplicationExecutionState previousState = ApplicationExecutionState.Running, NavigationReplacementMode forceReplaceCurrent = NavigationReplacementMode.ReplaceIfDifferent, bool clearHistory = true)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
// This Root Frame contains the media element!
rootFrame = new Frame();
rootFrame.Style = Resources["RootFrameStyle"] as Style;
App.NAVIGATION_EMPTY = rootFrame.GetNavigationState(); // Save the wasEmpty navigation state
TuneOut.Common.SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
if (previousState == ApplicationExecutionState.Terminated)
{
// Restore the saved session state only when appropriate
try
{
await TuneOut.Common.SuspensionManager.RestoreAsync();
}
catch (TuneOut.Common.SuspensionManagerException)
{
// Something went wrong restoring state.
// Assume there is no state and continue
}
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (clearHistory && NAVIGATION_EMPTY != null)
{
rootFrame.SetNavigationState(NAVIGATION_EMPTY);
}
if (forceReplaceCurrent == NavigationReplacementMode.AlwaysReplace && !rootFrame.Navigate(pageType, parameter))
{
throw new Exception("Failed to navigate to page");
}
else if (forceReplaceCurrent == NavigationReplacementMode.ReplaceIfDifferent && rootFrame.CurrentSourcePageType != pageType && !rootFrame.Navigate(pageType, parameter))
{
throw new Exception("Failed to navigate to page");
}
else if (rootFrame.Content == null && !rootFrame.Navigate(pageType, parameter))
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
throw new Exception("Failed to create initial page");
}
// Ensure the current window is active
Window.Current.Activate();
}