Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UriMapping Class

May 11, 2014

Defines the pattern for converting a requested uniform resource identifier (URI) into a new URI.

System.Object
  System.Windows.Navigation.UriMapping

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

public sealed class UriMapping
<sdk:UriMapping .../> 

The UriMapping type exposes the following members.

  NameDescription
Public methodUriMappingInitializes a new instance of the UriMapping class.
Top

  NameDescription
Public propertyMappedUriGets or sets the uniform resource identifier (URI) that is navigated to instead of the originally requested URI.
Public propertyUriGets or sets the pattern to match when determining if the requested uniform resource identifier (URI) is converted to a mapped URI.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodMapUriConverts the specified uniform resource identifier (URI) to a new URI, if the specified URI matches the defined template for converting.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The UriMapping class enables you to specify that a particular URI is converted into another URI. You map one URI to another URI when you want to provide a user-friendly URI that does not map to the physical location of a file. 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 and the URIs you have mapped will still work correctly.

You specify the pattern of a URI to match in the Uri property. You specify in the MappedUri property the URI to navigate to when the pattern is matched.

The UriMapper class has a UriMappings property which contains a collection of UriMapping objects. You add UriMapping objects to this collection to define the how URIs are converted in your application. You define the UriMapper object for a frame by assigning the UriMapper object to the UriMapper property of the frame.

The pattern you specify in the Uri property does not have to be 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 of the mapped URI where the matching {type} value is defined.

The query string of the requested URI is not evaluated when determining if the requested URI matches the pattern. For example, a value of Home in the Uri property will match a request with #Home or #Home? and any number of query string values.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Show:
© 2014 Microsoft