1

我有两个页面:page1.xamlpage2.xaml。我在 page1.xaml 上创建了一个按钮;在其单击事件中,我导航到page2.xaml。当我运行应用程序时,它失败了,调试器将我放到App.xaml.cs中。下面是我的代码:

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));    
    } 
}
4

1 回答 1

1

源页面.xaml

bookName.Id 获取 Id 和 book 并通过 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;
   }
于 2013-09-24T10:37:11.690 回答