I'm attempting to set up a URI mapper so that in the end, I can pass a query string to the xaml page I am loading.
Here's what I have defined in the XAML.
<navigation:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="RequirementOverview/{id}" MappedUri="/View/Pages/RequirementOverview.xaml?id={id}" />
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/View/Pages/{pageName}.xaml"/>
</uriMapper:UriMapper>
</navigation:Frame.UriMapper>
My Intention is that if you click on a link such as '/RequirementOverview/Foo' "Foo" is passed as a query string to the Requirement page, and then we can do our magic with it.
However when calling Fame.Navigate("RequirementOverview/Foo", UriKind.Relative) I always end up at the page like thus: hostpage.aspx#/RequirementOverview/Foo and no query is passed to the page. Rather, it seems to work (the navigation), but my navigationContext queryString comes back null.
Is my approach for this incorrect? Thanks in advance.
The URL that you get in the bowser (hostpage.aspx#/RequirementOverview/Foo) is what you should expect since you're using mapped URIs.
To get the
QueryString
parameters, all you have to do is override theOnNavigatedTo
of your page, access theQueryString
(which is aDictionary<string,string>
) property of theNavigationContext
which is a member of thePage
class, like this:Hope this helps :)