2011-11-08 50 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