I have a XAML page in a separate Windows Phone class library. The library is included in my VS solution and referenced from my app project. Let's say the page is called TestPage.xaml and it's in the root folder of my library called SharedPages.
I'd like to navigate to this page in my app using the NavigationService. I found this post which suggests using this URI format:
/{assemblyName};component/{pathToResource}
So I'm trying something like this:
NavigationService.Navigate(new Uri("/SharedPages;component/TestPage.xaml"));
When I run this I get the following exception:
Navigation is only supported to relative URIs that are fragments, or begin with '/', or which contain ';component/'.
What am I doing wrong?
Thanks.
Looks like the URI needs to be created as a relative URI. This works:
NavigationService.Navigate(new Uri("/SharedPages;component/TestPage.xaml", UriKind.Relative));
Hey I don't think it's your case, but it's good to review the generated assembly name.
Option 1) Incorrect Assembly name
The following format:
/{assemblyName};component/{pathToResource}
The assembly name can be checked it in the tab properties of the project. I remember a guy who has renamed the project but not the assembly and that was a reason because of the navigation was failing.
Option 2)
Dot separator in your assembly name.
I don't know the real reason of this, but I took me some time to found it. The name of the assembly must not have any dot as separator. I guess the Uri parse will incorrectly the Uri. For example I had an assembly called: "Com.Hmb.Prax" and I got the following exception:
Navigation is only supported to relative URIs that are fragments, or begin with '/', or which contain ';component/'.
Parameter name: uri
Once I rename my dll to "ComHmbPrax" it worked well. Herber
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With