0

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 a c# 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.

elnigno
  • 1,751
  • 14
  • 37
Jooki
  • 16
  • 2
  • It should break there, since when you're running the app with a debugger, it jumps there when an untreated exception happened and the application would crush otherwise. The second code sample you show is pretty much useless because it does not say anything. When the exception happens there should be an infowindow that says more about it. Try updating your question with some information from it. – mishan Nov 08 '13 at 10:07
  • I've looked at other help topics on this and the ;component element seemed like the only thing I was missing from my code, which is why I tried using it. I don't get any specific errors it just breaks on the above code. – Jooki Nov 08 '13 at 10:28

3 Answers3

0

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.

ZombieSheep
  • 29,603
  • 12
  • 67
  • 114
  • I am trying to access another project within my solution. If you say this isn't possible then I need to go back to the drawing board. – Jooki Nov 08 '13 at 10:21
  • 1
    I've seen apps that use more than one project in a solution surely there must be a way to navigate between them, it seems strange that this isn't possible. Do you know of any work arounds for this or do I just need to bite the bullet and combine my projects? – Jooki Nov 08 '13 at 10:32
0

You have an extra space after "component" in the Uri.

new Uri("/ChatMeApp;component/MainPage.xaml", UriKind.Relative));
Anton Sizikov
  • 9,105
  • 1
  • 28
  • 39
0

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));
}
user2420211
  • 280
  • 1
  • 3
  • 11