My problem is in navigating to another project file "ChatMeApp/MainPage.xaml" from my original project. My code is
private void GoToChat(object sender, EventArgs e)
{
this.NavigationService.Navigate(new Uri("/ChatMeApp;component MainPage.xaml", UriKind.RelativeOrAbsolute));
}
When I run this I get an exception in app.xaml.cs and it breaks here
// Code to execute if a navigation fails
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
// A navigation has failed; break into the debugger
System.Diagnostics.Debugger.Break();
}
}
I'm fairly new to WP8 development (coming from ac# background). All the advise I've seen makes me think this should work, can any one see a problem with it or suggest what else the problem might be.
I am assuming that you are trying to navigate to /MainPage.xaml within your current project . In that case you can achieve your goal with the following code.
private void GoToChat(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
If you are trying to navigate to a page in another app, this isn't possible.
您在Uri中的“组件”之后有一个额外的空间。
new Uri("/ChatMeApp;component/MainPage.xaml", UriKind.Relative));
Actullay you are trying to Navigate to another Assembly, you can also achive this by the source code pasted below.
Both case are pasted below
private void Button_Click_1(object sender, RoutedEventArgs e)
{
//Navigate to a page in the current assembly
NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
}
private void Button_Click(object sender, RoutedEventArgs e)
{
//Navigate to a page in an external referenced assembly
NavigationService.Navigate(new Uri("/AnotherProject;component/MainPage.xaml", UriKind.Relative));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.