wp根据条件动态改变应用程序默认首页
(1)WMAppManifest.xml默认应用程序启动首页 <DefaultTask Name ="_default" NavigationPage="Page.xaml"/> (2)APP构造函数中加入 RootFrame.Navigating += new NavigatingCancelEventHandler(RootFrame_Navigating); private void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e) { if (true)//判断的条件 { if (e.Uri.ToString().Contains("Page.xaml") != true) { return; } e.Cancel = true; RootFrame.Dispatcher.BeginInvoke(delegate { RootFrame.Navigate(new Uri("Page1.xaml", UriKind.Relative));//更改默认首页 }); } } |