当前位置: 首页>>代码示例>>C#>>正文


C# Frame.SetNavigationState方法代码示例

本文整理汇总了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();
        }
开发者ID:AlexWitteveen,项目名称:BibleApp,代码行数:38,代码来源:App.xaml.cs

示例2: RestoreFrameNavigationState

 private static void RestoreFrameNavigationState(Frame frame)
 {
     var frameState = SessionStateForFrame(frame);
     if (frameState.ContainsKey("Navigation"))
     {
         frame.SetNavigationState((String)frameState["Navigation"]);
     }
 }
开发者ID:RafaelPlantard,项目名称:DribbbleForWindowsPhone,代码行数:8,代码来源:SuspensionManager.cs

示例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;
        }
开发者ID:andyhammar,项目名称:UwpPlayground,代码行数:56,代码来源:App.xaml.cs

示例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();
        }
开发者ID:forehalo,项目名称:UWP-dev,代码行数:56,代码来源:App.xaml.cs

示例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;
        }
开发者ID:evangelism,项目名称:Win10UWPCourse,代码行数:54,代码来源:App.xaml.cs

示例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();
        }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:51,代码来源:App.xaml.cs

示例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();
        }
开发者ID:dube0141,项目名称:Space-Invaders-Mobile,代码行数:49,代码来源:App.xaml.cs

示例8: RestoreFrameNavigationState

 private void RestoreFrameNavigationState(Frame frame)
 {
     if (_sessionState.ContainsKey("Navigation") && _sessionState["Navigation"].ContainsKey("NavigationState"))
     {
         frame.SetNavigationState((string)_sessionState["Navigation"]["NavigationState"]);
     }
 }
开发者ID:ryanhorath,项目名称:Rybird.Framework,代码行数:7,代码来源:SessionStateService.cs

示例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"]);
     }
 }
开发者ID:Aadeelyoo,项目名称:MyMSDNSamples,代码行数:14,代码来源:SuspensionManager.cs

示例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;
                }
            };

        }
开发者ID:Ronacs,项目名称:WinDevCamp,代码行数:67,代码来源:App.xaml.cs

示例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");
                }
            }
        }
开发者ID:roachhd,项目名称:filter-explorer,代码行数:56,代码来源:App.xaml.cs

示例12: RecoverNavigationState

        private void RecoverNavigationState(Frame rootFrame)
        {
            var naviState = ApplicationData.Current.LocalSettings.Values["naviState"] as string;
            if (naviState == null) return;

            rootFrame.SetNavigationState(naviState);
        }
开发者ID:andyhammar,项目名称:win10apps-deepdive,代码行数:7,代码来源:App.xaml.cs

示例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();
        }
开发者ID:SplendidSky,项目名称:Visual-Studio-2015,代码行数:51,代码来源:App.xaml.cs


注:本文中的Windows.UI.Xaml.Controls.Frame.SetNavigationState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。