我想在启动应用程序或激活后检查 BackgroundAudioPlayer 是否正在播放,如果是,则转到带有播放器的页面。我知道我不能使用 NavigationService,并且我发现在 App.xaml.cs 中我应该像在 Activated 中一样使用 RootVisual,但它不起作用。RootVisual 为空。第一个没有错误,但问题是我到了 MainPage.xaml。那么我该如何解决呢?谢谢
private void Application_Launching(object sender, LaunchingEventArgs e)
{
if (BackgroundAudioPlayer.Instance.PlayerState == PlayState.Playing)
RootFrame.Navigate(new Uri("/PlayerPage.xaml", UriKind.RelativeOrAbsolute));
}
private void Application_Activated(object sender, ActivatedEventArgs e)
{
if (BackgroundAudioPlayer.Instance.PlayerState == PlayState.Playing)
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/PlayerPage.xaml", UriKind.RelativeOrAbsolute));
}