Navigating from App.xaml.cs

前端 未结 3 1231
执笔经年
执笔经年 2021-02-20 12:46

I want to add an application bar to multiple pages of my app. So, I\'m defining the application bar as an application resource so that it can be used by multiple pages. Now, the

3条回答
  •  醉梦人生
    2021-02-20 12:59

    I found this approach a better one. The RootFrame object is already in the App.xaml.cs file, you just need to call it. Also putting this in a UI thread dispatcher is safer.

     Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        // change UI here
                        RootFrame.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                    });
    

提交回复
热议问题