示例#1
0
        /// <summary>
        /// Handles bootstrapping the main frame and initial navigation.
        /// </summary>
        /// <param name="file">The file the app was opened with, or null (e.g. for regular launches).</param>
        protected void StartApp(StorageFile file)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                //this.DebugSettings.EnableFrameRateCounter = true;
                DebugSettings.IsBindingTracingEnabled = true;
                DebugSettings.BindingFailed          += (s, a) =>
                {
                    DebugHelper.Trace(a.Message);
                };
            }
#endif

            ActivationMode activationMode = (file == null ? ActivationMode.Regular : ActivationMode.File);
            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(320, 800 / 1.5));

            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(RootView),
                                   new NavigationParameter(
                                       new
                {
                    activationMode = activationMode,
                    openedFile     = file
                }
                                       )
                                   );
            }
            else
            {
                RootView rootView = RootFrame.Content as RootView;
                DebugHelper.Assert(rootView != null);

                if (file != null)
                {
                    rootView.OpenFile(new StorageFileWrapper(file));
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }