コード例 #1
0
ファイル: App.xaml.cs プロジェクト: astondg/feed-time
        private async Task CreateRootFrame(LaunchActivatedEventArgs e)
        {
            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();

                // TODO: change this value to a cache size that is appropriate for your application
                rootFrame.CacheSize = 1;

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

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                Type typeOfFirstPage = string.IsNullOrWhiteSpace(SettingsViewModel.Current.MobileServicesUserId)
                                        ? typeof(SplashPage)
                                        : await NavigationHelper.DetermineFirstPage();

                // If arguments have been passed, e.g. from an NFC tag, then navigate to the appropriate page.
                // Set up pages, like create/select baby, take precedence over NFC activation
                // but we still need to remember follow the NFC activation once set up is complete by passing
                // the existing navigation arguments
                if (typeOfFirstPage == typeof(MainPage))
                {
                    typeOfFirstPage = NavigationHelper.DeterminePageFromNavigationArguments(e.Arguments);
                }

#if WINDOWS_PHONE_APP
                // 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;
#endif

                // 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(typeOfFirstPage, e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
        }