2013-07-22 90 views
1

page2.xaml我有兩個頁面:的Page1.xamlpage2.xaml。我在page1.xaml上創建了一個按鈕;在其點擊事件中,我導航到page2.xaml。當我運行該應用程序時,它失敗,調試器將我放入App.xaml.cs。下面是我的代碼:導航要在Windows Phone 8

private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)     
{ 
    if (Debugger.IsAttached) 
    { 
     // A navigation has failed; break into the debugger      
     Debugger.Break();    
    }   
} 

我page1.xaml.cs後面的代碼是:

public partial class MainPage : PhoneApplicationPage  
{ 
    // Constructor 
    public MainPage() 
    { 
     InitializeComponent(); 
     // Sample code to localize the ApplicationBar       
     //BuildLocalizedApplicationBar(); 
    } 

    private void btnDownloded_Click(object sender, RoutedEventArgs e)   
    {    
     NavigationService.Navigate(new Uri("/DownloadedBooksPortrait.xaml", UriKind.Relative));  
    } 
} 
+0

首先檢查你的..私人無效RootFrame_NavigationFailed(對象發件人,NavigationFailedEventArgs E) { 如果(Debugger.IsAttached) { //一種導航已失敗發送者指針通過放異常的類型;闖入調試器 Debugger.Break(); } } 當你得到這個錯誤..comment以下關於錯誤..並確保你的xaml代碼是正確的.. – loop

回答

1

SourcePage.xaml

bookName.Id獲取Id和書通過和bookid我們將在我們的目的地頁面上獲得該ID並顯示數據。

NavigationService.Navigate(new Uri("/MainPage.xaml?selectedItem=" +bookName.Id, UriKind.Relative)); 

DestinationPage.xaml

在目標頁面我們,我們將下面讀取查詢參數。

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) 
    { 
     string dir = "Hello" + selectedItem; 
    }