UriMapper Problem
        Posted  
        
            by jsop
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by jsop
        
        
        
        Published on 2010-04-16T17:30:25Z
        Indexed on 
            2010/04/16
            17:33 UTC
        
        
        Read the original article
        Hit count: 349
        
silverlight-3.0
I have the following xaml (nonessential markup removed in the interest of brevity):
<navigation:Frame x:Name="ContentFrame" >
    <navigation:Frame.UriMapper>
        <uriMapper:UriMapper>
            <uriMapper:UriMapping Uri="/{pageName}" 
                                  MappedUri="/Views/{pageName}.xaml"/>
            <uriMapper:UriMapping Uri="/FMChart/{metricID}/{orgID}" 
                                  MappedUri="/Views/FMChart.xaml?metricID={metricID}&orgID={orgID}"/>
        </navigation:Frame.UriMapper>
    </navigation:Frame.UriMapper>
</navigation:Frame>
I'm creating the HyperLinkButton objects dynamically (in code), like so:
int metricID = 1;
int orgID = 1;
HyperlinkButton button = new HyperlinkButton();
button.Name        = Guid.NewGuid().ToString();
button.TargetName  = "ContentFrame";
// this string doesn't work
string url = string.Format("/FMChart/{0}/{1}", metricID, orgID);
button.NavigateUri = new Uri(url, UriKind.Relative);
When I click the bbutton, the browser renders a blank page, and eventually presents me with a REALLY long stack trace (InvalidOperation exception). If I take the parameters out of th indicated line:
string url = "/FMChart";
...it works as expected (brings up the desired page).
I've also tried the following strings:
/FMChart/{0}&{1}
/FMChart/{0}& amp;{1}
What am I doing wrong?
© Stack Overflow or respective owner