我有两个页面: page1.xaml 和 page2.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));
}
}
答案 0 :(得分: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;
}