![](/img/trans.png)
[英]How to access element of MainPage.xaml into another page in uwp application?
[英]How we redirect the Page to MainPage.xaml
我需要在silverlight應用程序中從LogInPage重定向到MainPage.xaml。我使用以下方式,
((LogInPage)App.Current.RootVisual).ContentFrame.Navigate(new Uri("/ShowQueue", UriKind.Relative));
NavigationService.Navigate(new Uri("/MainPage", UriKind.Relative));
但是我沒有實現?它得到了錯誤。
1. App.xaml.cs文件中的代碼:
Grid rootvisual = new Grid();
public void GotoPage(UserControl nextPage)
{
App app = (App)Application.Current;
app.rootvisual.Children.Clear();
app.rootvisual.Children.Add(nextPage);
}
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = rootvisual;
rootvisual.Children.Add(new LoginPage());
}
然后在登錄頁面中調用GotoPage(new MainPage())
。 或使用NavigationService.Navigate(new Uri("MainPage.xaml", UriKind.Relative));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.