Share via


UriMapper Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Converts a uniform resource identifier (URI) into a new URI based on the rules of a matching object specified in a collection of mapping objects.

Inheritance Hierarchy

System.Object
  System.Windows.Navigation.UriMapperBase
    System.Windows.Navigation.UriMapper

Namespace:  System.Windows.Navigation
Assembly:  System.Windows.Controls.Navigation (in System.Windows.Controls.Navigation.dll)

Syntax

'Declaration
<ContentPropertyAttribute("UriMappings")> _
Public NotInheritable Class UriMapper _
    Inherits UriMapperBase
[ContentPropertyAttribute("UriMappings")]
public sealed class UriMapper : UriMapperBase
<sdk:UriMapper>
  oneOrMoreUriMappings
</sdk:UriMapper> 

XAML Values

  • oneOrMoreUriMappings
    One or more UriMapping object elements.

The UriMapper type exposes the following members.

Constructors

  Name Description
Public method UriMapper Initializes a new instance of the UriMapper class.

Top

Properties

  Name Description
Public property UriMappings Gets a collection of objects that are used to convert a uniform resource identifier (URI) into a new URI.

Top

Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method MapUri Converts a specified uniform resource identifier (URI) into a new URI based on the rules of a matching object in the UriMappings collection. (Overrides UriMapperBase.MapUri(Uri).)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

You use the UriMapper class to store the collection of UriMapping objects to use for converting a requested URI to another URI. You define the UriMapper object and its collection of UriMapping objects for a frame by assigning the UriMapper object to the UriMapper property of the frame.

The UriMappings property contains the collections of mapping objects. The MapUri method converts a requested URI to the new URI based on the mappings you defined in objects you added to the UriMappings property.

Typically, you will not need to programmatically call the MapUri method. The Silverlight framework automatically calls the MapUri method for each request when you have added an instance of the UriMapper class to your application.

Examples

The following example shows an instance of UriMapper that is defined within a frame named ContentFrame. The element contains a collection of UriMapping objects.

<sdk:Frame 
       x:Name="ContentFrame" 
       Style="{StaticResource ContentFrameStyle}" 
       Source="/Home" 
       Navigated="ContentFrame_Navigated" 
       NavigationFailed="ContentFrame_NavigationFailed">
    <sdk:Frame.UriMapper>
        <sdk:UriMapper>
            <sdk:UriMapping 
                Uri="/ProductDetail/{productid}" 
                MappedUri="/Views/ProductDetail.xaml?ProductId={productid}"/>
            <sdk:UriMapping 
                Uri="/Reports/{type}/{selection}" 
                MappedUri="/Views/ReportsPage.xaml?type={type}&amp;selection={selection}"/>
            <sdk:UriMapping 
                Uri="/{pageName}" 
                MappedUri="/Views/{pageName}.xaml"/>
        </sdk:UriMapper>
    </sdk:Frame.UriMapper>
</sdk:Frame>

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

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

See Also

Reference

Other Resources