Uri Property
Collapse the table of content
Expand the table of content

UriMapping.Uri Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the pattern to match when determining if the requested uniform resource identifier (URI) is converted to a mapped URI.

Namespace:  System.Windows.Navigation
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)
XMLNS for XAML: Not mapped to an xmlns.

'Declaration
Public Property Uri As Uri
<sdk:UriMapping Uri="uriString"/>

Property Value

Type: System.Uri
The URI that will be converted.

When a requested URI matches the pattern you specify in the Uri property, the Windows Phone framework navigates to the URI you specify in the MappedUri property. Typically, you set the Uri property to a user-friendly value, such as Home, and you set the MappedUri property to the actual file to use for the request, such as /Views/HomePage.xaml.

You map a matching URI for only the portion of the URI that pertains to navigation within the frame that contains the mappings. For a browser-integrated application, this portion is found after the fragment delimiter (#). For example, if your browser-integrated Windows Phone application is hosted at http://www.contoso.com/Default.aspx, you specify a matching URI for http://www.contoso.com/Default.aspx#Home by creating an instance of UriMapping that matches Home. Therefore, you can move your Windows Phone application to a different Web page and the URIs you have mapped will still work correctly.

The Uri property contains the pattern, which is not necessarily the exact URI, to match against the requested URI. The pattern can include placeholder segments in the URI that will match any value in that segment. You specify a placeholder segment by enclosing the name of the segment with the curly braces ( { and } ). These placeholder segments act as variables when mapping to the URI. For example, in the App.xaml file you can specify the following UriMapping instance:

<sdk:UriMapping Uri="Products/{type}" 
  MappedUri="/Views/ProductDetail.xaml?producttype={type}">
</sdk:UriMapping>

The pattern Products/{type} will match any request that includes Products followed by a segment. The matching URIs could include Products/bikes, Products/kitchen or any other similar request. The value specified in the second segment is included in the query string where the matching {type} value is defined.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft