本文整理匯總了C#中Windows.UI.Xaml.Controls.Frame.SetNavigationState方法的典型用法代碼示例。如果您正苦於以下問題:C# Frame.SetNavigationState方法的具體用法?C# Frame.SetNavigationState怎麽用?C# Frame.SetNavigationState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.UI.Xaml.Controls.Frame
的用法示例。
在下文中一共展示了Frame.SetNavigationState方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnLaunched
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
if (ApplicationData.Current.LocalSettings.Values.ContainsKey("App.NavigationState"))
{
rootFrame.SetNavigationState(ApplicationData.Current.LocalSettings.Values["App.NavigationState"] as string);
}
}
Window.Current.Content = rootFrame;
}
SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;
rootFrame.Navigated += RootFrame_Navigated;
if (rootFrame.Content == null)
{
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
Window.Current.Activate();
}
示例2: RestoreFrameNavigationState
private static void RestoreFrameNavigationState(Frame frame)
{
var frameState = SessionStateForFrame(frame);
if (frameState.ContainsKey("Navigation"))
{
frame.SetNavigationState((String)frameState["Navigation"]);
}
}
示例3: OnLaunched
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
ApplicationData.Current.DataChanged += Current_DataChanged;
var lastState = e.PreviousExecutionState;
CheckState(lastState);
var kind = e.Kind;
CheckKind(kind);
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
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
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
var naviState = (string)ApplicationData.Current.LocalSettings.Values["naviState"];
rootFrame.SetNavigationState(naviState);
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof (MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
var systemNavigationManager = SystemNavigationManager.GetForCurrentView();
systemNavigationManager.BackRequested += App_BackRequested;
}
示例4: OnLaunched
/// <summary>
/// 在應用程序由最終用戶正常啟動時進行調用。
/// 將在啟動應用程序以打開特定文件等情況下使用。
/// </summary>
/// <param name="e">有關啟動請求和過程的詳細信息。</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
// 不要在窗口已包含內容時重複應用程序初始化,
// 隻需確保窗口處於活動狀態
if (rootFrame == null)
{
// 創建要充當導航上下文的框架,並導航到第一頁
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated ||
e.PreviousExecutionState == ApplicationExecutionState.ClosedByUser)
{
//TODO: 從之前掛起的應用程序加載狀態
object value;
var localSettings = ApplicationData.Current.LocalSettings;
if (localSettings.Values.TryGetValue("nav", out value))
{
rootFrame.SetNavigationState(value as string);
}
else
{
rootFrame.Navigate(typeof(MainPage));
}
}
// 將框架放在當前窗口中
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// 當導航堆棧尚未還原時,導航到第一頁,
// 並通過將所需信息作為導航參數傳入來配置
// 參數
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// 確保當前窗口處於活動狀態
Window.Current.Activate();
}
示例5: OnLaunched
/// <summary>
/// Вызывается при обычном запуске приложения пользователем. Будут использоваться другие точки входа,
/// например, если приложение запускается для открытия конкретного файла.
/// </summary>
/// <param name="e">Сведения о запросе и обработке запуска.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = false;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
// Не повторяйте инициализацию приложения, если в окне уже имеется содержимое,
// только обеспечьте активность окна
if (rootFrame == null)
{
// Создание фрейма, который станет контекстом навигации, и переход к первой странице
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Загрузить состояние из ранее приостановленного приложения
if (ApplicationData.Current.LocalSettings.Values.ContainsKey("NavigationState"))
{
rootFrame.SetNavigationState((string)ApplicationData.Current.LocalSettings.Values["NavigationState"]);
}
}
// Размещение фрейма в текущем окне
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// Если стек навигации не восстанавливается для перехода к первой странице,
// настройка новой страницы путем передачи необходимой информации в качестве параметра
// параметр
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Обеспечение активности текущего окна
Window.Current.Activate();
SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;
rootFrame.Navigated += RootFrame_Navigated;
}
示例6: OnLaunched
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
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
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
var suspensionManager = new NavigationSuspensionManager();
string navigationState = await suspensionManager.GetNavigationStateAsync();
rootFrame.SetNavigationState(navigationState);
await DataManager.Instance.LoadTempSessionAsync();
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
示例7: OnLaunched
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
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
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//Load state from previously suspended application
if (ApplicationData.Current.LocalSettings.Values.ContainsKey("NavigationState"))
{
rootFrame.SetNavigationState((string)(ApplicationData.Current.LocalSettings.Values["NavigationState"]));
}
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
示例8: RestoreFrameNavigationState
private void RestoreFrameNavigationState(Frame frame)
{
if (_sessionState.ContainsKey("Navigation") && _sessionState["Navigation"].ContainsKey("NavigationState"))
{
frame.SetNavigationState((string)_sessionState["Navigation"]["NavigationState"]);
}
}
示例9: RestoreFrameNavigationState
/// <summary>
/// The restore frame navigation state.
/// </summary>
/// <param name="frame">
/// The frame.
/// </param>
private static void RestoreFrameNavigationState(Frame frame)
{
Dictionary<string, object> frameState = SessionStateForFrame(frame);
if (frameState.ContainsKey("Navigation"))
{
frame.SetNavigationState((string)frameState["Navigation"]);
}
}
示例10: OnLaunched
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
// How did the app exit the last time it was run (if at all)
ApplicationExecutionState previousState = e.PreviousExecutionState;
// What kind of launch is this?
ActivationKind activationKind = e.Kind;
//..
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
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// Set the frame navigation state that was serialized as a string when we suspended
if (ApplicationData.Current.LocalSettings.Values.ContainsKey("NavigationState"))
{
rootFrame.SetNavigationState((string)ApplicationData.Current.LocalSettings.Values["NavigationState"]);
}
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
// Every time the Frame navigates, set the visibility of the Shell-drawn back button
// appropriate to whether there is anywhere to go back to
rootFrame.Navigated += (s, a) =>
{
if (rootFrame.CanGoBack)
{
// Setting this visible is ignored on Mobile and when in tablet mode!
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
}
else
{
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
}
};
}
示例11: CreateRootFrame
private void CreateRootFrame(ApplicationExecutionState state, string launchArguments = null)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Black);
// TODO: change this value to a cache size that is appropriate for your application
rootFrame.CacheSize = 0;
if (state == ApplicationExecutionState.Terminated)
{
SessionModel.Instance.Restore();
var settings = Windows.Storage.ApplicationData.Current.LocalSettings;
if (settings.Values.ContainsKey("NavigationState"))
{
rootFrame.SetNavigationState(settings.Values["NavigationState"] as string);
}
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync().AsTask().Wait();
}
if (rootFrame.Content == null)
{
// Removes the turnstile navigation for startup.
if (rootFrame.ContentTransitions != null)
{
this.transitions = new TransitionCollection();
foreach (var c in rootFrame.ContentTransitions)
{
this.transitions.Add(c);
}
}
rootFrame.ContentTransitions = null;
rootFrame.Navigated += this.RootFrame_FirstNavigated;
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (!rootFrame.Navigate(typeof(Views.StreamPage), launchArguments))
{
throw new Exception("Failed to create initial page");
}
}
}
示例12: RecoverNavigationState
private void RecoverNavigationState(Frame rootFrame)
{
var naviState = ApplicationData.Current.LocalSettings.Values["naviState"] as string;
if (naviState == null) return;
rootFrame.SetNavigationState(naviState);
}
示例13: OnLaunched
/// <summary>
/// 在應用程序由最終用戶正常啟動時進行調用。
/// 將在啟動應用程序以打開特定文件等情況下使用。
/// </summary>
/// <param name="e">有關啟動請求和過程的詳細信息。</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = false;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
// 不要在窗口已包含內容時重複應用程序初始化,
// 隻需確保窗口處於活動狀態
if (rootFrame == null)
{
// 創建要充當導航上下文的框架,並導航到第一頁
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: 從之前掛起的應用程序加載狀態
if (ApplicationData.Current.LocalSettings.Values.ContainsKey("NavigationState"))
{
rootFrame.SetNavigationState((string)ApplicationData.Current.LocalSettings.Values["NavigationState"]);
}
}
// 將框架放在當前窗口中
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// 當導航堆棧尚未還原時,導航到第一頁,
// 並通過將所需信息作為導航參數傳入來配置
// 參數
rootFrame.Navigate(typeof(MainPage));
}
// 確保當前窗口處於活動狀態
Window.Current.Activate();
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
LoadDatabase();
Todos.ViewModels.TodoItemViewModel.LoadAll();
}