當前位置: 首頁>>代碼示例>>C#>>正文


C# Frame.Navigate方法代碼示例

本文整理匯總了C#中Windows.UI.Xaml.Controls.Frame.Navigate方法的典型用法代碼示例。如果您正苦於以下問題:C# Frame.Navigate方法的具體用法?C# Frame.Navigate怎麽用?C# Frame.Navigate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.UI.Xaml.Controls.Frame的用法示例。


在下文中一共展示了Frame.Navigate方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnLaunched

        /// <summary>
        /// Setup the application and initialize the tests.
        /// </summary>
        /// <param name="args">
        /// Details about the launch request and process.
        /// </param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            // Do not repeat app initialization when already running, just
            // ensure that the window is active
            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                Window.Current.Activate();
                return;
            }

            // Set the App Mode and configuration based on the arguments
            Harness.SetAutoConfig(args.Arguments);
            Frame rootFrame = new Frame();

            if (Harness.Settings.ManualMode)
            {
                rootFrame.Navigate(typeof(MainPage));
            }
            else
            {
                rootFrame.Navigate(typeof(TestPage));
            }

            Window.Current.Content = rootFrame;
            Window.Current.Activate();
        }
開發者ID:brettsam,項目名稱:azure-mobile-apps-net-client,代碼行數:32,代碼來源:App.xaml.cs

示例2: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            // Do not repeat app initialization when already running, just ensure that
            // the window is active
            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                Window.Current.Activate();
                return;
            }

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Create a Frame to act navigation context and navigate to the first page
            var rootFrame = new Frame();
            SimpleIoc.Default.Register<INavigationService>(() => new NavigationService(rootFrame));

            if (!ApplicationData.Current.LocalSettings.Values.ContainsKey("SimBalanceBackgroundTask"))
            {
                //Register background worker
                var backgroundTaskManager = new BackgroundTaskBuilder
                                                {
                                                    TaskEntryPoint =
                                                        "MobileVikings.FrontEnd.BackgroundTasks.SimBalanceBackgroundTask",
                                                    Name = "SimBalanceBackgroundTask"
                                                };

                backgroundTaskManager.SetTrigger(new MaintenanceTrigger(15, false));
                backgroundTaskManager.AddCondition(new SystemCondition(SystemConditionType.InternetAvailable));
                var registration = backgroundTaskManager.Register();
                ApplicationData.Current.LocalSettings.Values["SimBalanceBackgroundTask"] = true;
            }

            if (ApplicationData.Current.RoamingSettings.Values["AuthorizationInfo"] == null)
            {
                if (!rootFrame.Navigate(typeof(LoginView)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            else
            {
                if (!rootFrame.Navigate(typeof(MainView)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            

            // Place the frame in the current Window and ensure that it is active
            Window.Current.Content = rootFrame;
            Window.Current.Activate();
        }
開發者ID:prebenh,項目名稱:MobileVikings,代碼行數:61,代碼來源:App.xaml.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="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {

#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 (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                Harness.SetAutoConfig(args.Arguments);

                if (Harness.Settings.ManualMode)
                {
                    rootFrame.Navigate(typeof(MainPage));
                }
                else
                {
                    rootFrame.Navigate(typeof(TestPage));
                }
                // 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), args.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
開發者ID:Azure,項目名稱:azure-mobile-apps-net-client,代碼行數:55,代碼來源:App.xaml.cs

示例4: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            // TODO: Create a data model appropriate for your problem domain to replace the sample data
            var sampleData = new SampleDataSource();

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Create a Frame to act navigation context and navigate to the first page,
            // configuring the new page by passing required information as a navigation
            // parameter
            var rootFrame = new Frame();
            rootFrame.Navigate(typeof(Dashboard), sampleData);

            // Place the frame in the current Window and ensure that it is active
            Window.Current.Content = rootFrame;
            Window.Current.Activate();

            // move to an appropriate place
            var liveTiles = new LiveTiles();
            liveTiles.ShowAsLiveTile("Wash the car");
            liveTiles.ShowAsLiveTile("Do the dishes");
            liveTiles.ShowAsLiveTile("Show the app");
            liveTiles.ShowAsLiveTile("Mow the lawn");
            liveTiles.ShowAsBadge(6);
            liveTiles.ShowAsToast("Woot, a toast!");
        }
開發者ID:Goeleven,項目名稱:Goeleven.Windows8,代碼行數:35,代碼來源:App.xaml.cs

示例5: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            // Do not repeat app initialization when already running, just ensure that
            // the window is active
            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                Window.Current.Activate();
                return;
            }

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Create a Frame to act navigation context and navigate to the first page
            var rootFrame = new Frame();
            if (!rootFrame.Navigate(typeof(MainPage)))
            {
                throw new Exception("Failed to create initial page");
            }
            /// <summary>
            /// Invoked when application execution is being suspended.  Application state is saved
            /// without knowing whether the application will be terminated or resumed with the contents
            /// of memory still intact.
            /// </summary>
            /// <param name="sender">The source of the suspend request.</

            // Place the frame in the current Window and ensure that it is active
            Window.Current.Content = rootFrame;
            Window.Current.Activate();
        }
開發者ID:dotnetcurry,項目名稱:zumo-and-tick-tac-toe-leaderboard,代碼行數:38,代碼來源:App.xaml.cs

示例6: OnLaunched

 protected override void OnLaunched(LaunchActivatedEventArgs args)
 {
     var rootFrame = new Frame();
     rootFrame.Navigate(typeof(DefaultPage));
     Window.Current.Content = rootFrame;
     Window.Current.Activate();
 }
開發者ID:oldnewthing,項目名稱:old-Windows8-samples,代碼行數:7,代碼來源:App.xaml.cs

示例7: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            // Do not repeat app initialization when already running, just ensure that
            // the window is active
            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                Window.Current.Activate();
                return;
            }

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Create a Frame to act navigation context and navigate to the first page
            var rootFrame = new Frame();
            if (!rootFrame.Navigate(typeof(MainPage)))
            {
                throw new Exception("Failed to create initial page");
            }

            // Place the frame in the current Window and ensure that it is active
            Window.Current.Content = rootFrame;
            Window.Current.Activate();

            TileUpdateManager.CreateTileUpdaterForApplication().StartPeriodicUpdate(
                new System.Uri(MobileService.ApplicationUri, "/api/notifications"),
                PeriodicUpdateRecurrence.HalfHour
            );
        }
開發者ID:kirpasingh,項目名稱:MicrosoftAzureTrainingKit,代碼行數:37,代碼來源:App.xaml.cs

示例8: OnLaunched

        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                Window.Current.Activate();
                return;
            }

            var rootFrame = new Frame();
            SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                await SuspensionManager.RestoreAsync();
            }

            if (rootFrame.Content == null)
            {
                if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups"))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            Window.Current.Content = rootFrame;
            Window.Current.Activate();
        }
開發者ID:shiftkey,項目名稱:bearded-dangerzone,代碼行數:27,代碼來源:App.xaml.cs

示例9: ProjectAsync

        public async Task<int> ProjectAsync(Type viewType, DeviceInformation device = null)
        {
            int mainViewId = ApplicationView.GetForCurrentView().Id;
            int? secondViewId = null;

            var view = CoreApplication.CreateNewView();
            await view.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                secondViewId = ApplicationView.GetForCurrentView().Id;
                var rootFrame = new Frame();
                rootFrame.Navigate(viewType, null);
                Window.Current.Content = rootFrame;
                Window.Current.Activate();
            });

            if (secondViewId.HasValue)
            {
                if(device == null)
                    await ProjectionManager.StartProjectingAsync(secondViewId.Value, mainViewId);
                else
                    await ProjectionManager.StartProjectingAsync(secondViewId.Value, mainViewId, device);
            }

            return mainViewId;
        }
開發者ID:dimkname,項目名稱:UAP-Samples,代碼行數:25,代碼來源:ProjectionService.cs

示例10: search

 private void search(object sender, RoutedEventArgs e)
 {
     Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
     main_page.App.key = s.Text;
     if (localSettings.Containers.ContainsKey(s.Text))
     {
         var rootFrame = new Frame();
         if (!rootFrame.Navigate(typeof(BlankPage3)))
         {
             throw new Exception("Failed to create initial page");
         } // Place the frame in the current Window and ensure that it is active
         Window.Current.Content = rootFrame;
         Window.Current.Activate();
     }
     else
     {
         var rootFrame = new Frame();
         if (!rootFrame.Navigate(typeof(BlankPage1)))
         {
             throw new Exception("Failed to create initial page");
         } // Place the frame in the current Window and ensure that it is active
         Window.Current.Content = rootFrame;
         Window.Current.Activate();
     }
 }
開發者ID:song-forever,項目名稱:wordblocks,代碼行數:25,代碼來源:MainPage.xaml.cs

示例11: OnActivated

        protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);

            if (args.Kind == ActivationKind.VoiceCommand)
            {
                var commandArgs = args as VoiceCommandActivatedEventArgs;
                SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;

                var text = speechRecognitionResult.Text;
                var status = speechRecognitionResult.Status;
                var commandName = speechRecognitionResult.RulePath[0];
                if(commandName == "command1")
                {

                }else if(commandName == "command2")
                {
                    Frame rootFrame = new Frame();
                    Window.Current.Content = rootFrame;

                    rootFrame.Navigate(typeof(SendPage),1);
                    Window.Current.Activate();
                }
                else if(commandName == "command3")
                {
                    Frame rootFrame = new Frame();
                    Window.Current.Content = rootFrame;

                    rootFrame.Navigate(typeof(SendPage),0);
                    Window.Current.Activate();
                }

            }
        }
開發者ID:garicchi,項目名稱:CortanaSlide,代碼行數:34,代碼來源:App.xaml.cs

示例12: OnLaunched

        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            // Do not repeat app initialization when already running, just ensure that the window is active
            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                Window.Current.Activate();
                return;
            }

            // Create a Frame to act as the navigation context and associate it with a SuspensionManager key
            var rootFrame = new Frame();
            SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                await SuspensionManager.RestoreAsync();
            }

            if (rootFrame.Content == null)
            {
                if (!rootFrame.Navigate(typeof(HomeView), "AllGroups"))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            Window.Current.Content = rootFrame;
            Window.Current.Activate();
        }
開發者ID:shiftkey,項目名稱:better-win8-templates,代碼行數:29,代碼來源:App.xaml.cs

示例13: InitialiseRootFrame

 private void InitialiseRootFrame(Frame rootFrame)
 {
     var networkProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
     if (networkProfile != null && networkProfile.GetNetworkConnectivityLevel() == Windows.Networking.Connectivity.NetworkConnectivityLevel.InternetAccess)
     {
         Window.Current.Content = new Pages.Shell(rootFrame);
         rootFrame.NavigationFailed += OnNavigationFailed;
         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(Pages.HomePage));
         }
     }
     else
     {
         rootFrame.Content = new TextBlock()
         {
             Text = "No internet connectivity",
             FontSize = 22,
             HorizontalAlignment = HorizontalAlignment.Center,
             VerticalAlignment = VerticalAlignment.Center
         };
         Window.Current.Content = rootFrame;
     }
 }
開發者ID:Pradyumna91,項目名稱:8tracksWin,代碼行數:27,代碼來源:App.xaml.cs

示例14: BackMain_OnClick

		private void BackMain_OnClick(object sender, RoutedEventArgs e)
		{
			var fr = new Frame();
			fr.Navigate(typeof(MainPage));
			Window.Current.Content = fr;
			Window.Current.Activate();
		}
開發者ID:kfwls,項目名稱:MissionControl-WinRT-Client,代碼行數:7,代碼來源:SubmitCompany.xaml.cs

示例15: CreateView_Click

        private async void CreateView_Click(object sender, RoutedEventArgs e)
        {
            // Set up the secondary view, but don't show it yet
            ViewLifetimeControl viewControl = null;
            await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                // This object is used to keep track of the views and important
                // details about the contents of those views across threads
                // In your app, you would probably want to track information
                // like the open document or page inside that window
                viewControl = ViewLifetimeControl.CreateForCurrentView();
                viewControl.Title = DEFAULT_TITLE;
                // Increment the ref count because we just created the view and we have a reference to it                
                viewControl.StartViewInUse();

                var frame = new Frame();
                frame.Navigate(typeof(SecondaryViewPage), viewControl);
                Window.Current.Content = frame;
                // This is a change from 8.1: In order for the view to be displayed later it needs to be activated.
                Window.Current.Activate();
                ApplicationView.GetForCurrentView().Title = viewControl.Title;
            });

            // Be careful! This collection is bound to the current thread,
            // so make sure to update it only from this thread
            ((App)App.Current).SecondaryViews.Add(viewControl);
        }
開發者ID:COMIsLove,項目名稱:Windows-universal-samples,代碼行數:27,代碼來源:Scenario1.xaml.cs


注:本文中的Windows.UI.Xaml.Controls.Frame.Navigate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。