C# UWP根帧与页帧
下面是典型的App.xaml.cs代码C# UWP根帧与页帧,c#,uwp,uwp-xaml,C#,Uwp,Uwp Xaml,下面是典型的App.xaml.cs代码 protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { //this.DebugSettings.EnableFrameRateCounter = true; } #endif
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
//this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
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;
rootFrame.Navigated += OnNavigated;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
// Register a handler for BackRequested events and set the
// visibility of the Back button
SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
rootFrame.CanGoBack ?
AppViewBackButtonVisibility.Visible :
AppViewBackButtonVisibility.Collapsed;
}
if (e.PrelaunchActivated == false)
{
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(SignInPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
}
当
rootFrame.Navigate(typeof(signingpage),例如Arguments)时调用code>,则创建SignInPage
。在SignInPage.xaml.cs
中,可能有如下代码:this.Frame.Navigate(typeof(FramePage))代码>。来自此.Frame.
的框架是否与根框架
相同?如果是,那么页面
类在何时何地从App.xaml.cs
获得根框架的分配?是的,这是相同的框架
对象,因为页面
引用了控制其内容的框架。换句话说,框架
,用于导航页面
帧
获取页面内容的控制框架
资料来源:
此属性在导航时自动设置,并首先在OnNavigatedTo
方法中的页面
对象中可用。是的,这与框架
对象相同,因为页面
引用了控制其内容的框架。换句话说,框架
,用于导航页面
帧
获取页面内容的控制框架
资料来源:
此属性在导航时自动设置,并首先在OnNavigatedTo
方法中的页面
对象中可用