2011-11-08 127 views
1

今天我开始学习如何开发Windows Phone,我有一个问题。如何在WP7中的屏幕之间切换?

我有一个主屏幕(MainPage.xaml)和第二个屏幕(TaskPage.xaml)。 我想在这些屏幕之间导航。

我写道:

 var frame = Application.Current.RootVisual as PhoneApplicationFrame; 
     frame.Source = new Uri("/TaskPage.xaml", UriKind.Relative); 

我在模拟器中运行它,但视觉工作室MainPage.g.i.is排队返回一个错误:

System.Windows.Application.LoadComponent(this, new System.Uri("/Appname;component/MainPage.xaml", System.UriKind.Relative)); 

的哪些错误?对不起,英文不好,谢谢你的回答。

回答

3

请尝试使用的NavigationService如:

NavigationService.Navigate(new Uri("/TaskPage.xaml", UriKind.Relative)); 

在你当前的代码你在哪里改变frame.Source。有关WP7导航的更大图片,请通读:WP7 Navigation Step by Step

+0

非常感谢您 – tbsasa