![](/img/trans.png)
[英]How do I change the page name for the root frame navigation in a Windows 10 UWP app?
[英]UWP Root frame vs Page frame
這是典型的App.xaml.cs代碼
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(SignInPage), e.Arguments);
調用, SignInPage
被創建。 在SignInPage.xaml.cs
,可能會有類似以下代碼: this.Frame.Navigate(typeof(FramePage));
。 是來自this.Frame.
的Frame
this.Frame.
和rootFrame
嗎? 如果是的話,那么在何時何地從App.xaml.cs
中為Page
類分配根框架?
是的,這是同一個Frame
對象,因為Page
引用了控制其內容的框架。 換句話說,導航到頁面的Frame
。
幀
獲取頁面內容的控制框架。
資料來源: docs.microsoft.com
此屬性在導航時自動設置,並且首先在OnNavigatedTo
方法的Page
對象中OnNavigatedTo
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.