Given a PhoneApplicationPage
sub type, is there a way (other than relying on convention) to figure out its internal uri?
In other words, I want to call GetUri<MyPage>()
and get back something like /Views/MyPage.xaml
.
Given a PhoneApplicationPage
sub type, is there a way (other than relying on convention) to figure out its internal uri?
In other words, I want to call GetUri<MyPage>()
and get back something like /Views/MyPage.xaml
.
There is no way to do this. There is no meta data that points relates a XAML file name to a type. The filename is essentially the key by which the runtime identifies the BAML to load and it's from that BAML that it knows the type. Going the other direction would be very difficult.
Short of reading the BAML resource streams and figuring out the mapping yourself (which can't easily be done in Silverlight and would kill performance even if it could) I can't see a way of doing this.
Will it be possible to do something similar to this:
C# Silverlight 3 - Programmatically Navigate Between Pages?
Where he is defining navigation mappings. I'll be trying this tonight in my app, I currently just maintain a static dictionary of page types against their URI; unfortunately this is all manual.
You have to store the Uri for a specific page on a custom class with dictionary for example or using the UriMapper. Maybe UriMapper is exatly what you are looking for.
Here is how to use it in Windows Phone http://www.windowsphonegeek.com/articles/All-about-UriMapping-in-WP7.