Skip to main content

Microsoft Silverlight

Answered Question Hyperlink button does not work when used in navigation pageRSS Feed

(0)

richardfen
richardfen

Member

Member

41 points

74 Posts

Hyperlink button does not work when used in navigation page

I have a HyperlinkButton with the NavigateUri defined as:

http://localhost/test/test.ppt

This works perfectly in a Silverlight app without navigation.  However, when I put the identical page into a Silverlight navigation app, I get the error:

     navigation is only supported to relative uris that are fragments, or begin with '/', or which contain ';component/'. urimapper

 From reading the forums, I know that this has something to do with UriMapping.  My MainPage.xaml looks like:

<navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}"

Source="/FencelForm" Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed">

<navigation:Frame.UriMapper>

<uriMapper:UriMapper>

<uriMapper:UriMapping Uri="" MappedUri="/Views/TestForm.xaml"/>

<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>

</uriMapper:UriMapper>

</navigation:Frame.UriMapper>

</navigation:Frame>

 where TestForm is my initial page.  This is the default stuff that is generated by visual studio.  The HyperlinkButton is in one of the pages that gets navigated to.   My understanding is that because my HyperlinkButton has an absolute address the UriMapping should not make any difference.  So I am totally confused.  I also need to know how to make it work with a relative address because I need it to allow the user to download a file local to the website.  Many thanks for your help.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Answered Question

Re: Hyperlink button does not work when used in navigation page

 If you specify TargetName="_new" or TargetName="_blank" on your HyperlinkButton. You should not get this error.

I'm not sure it is by design. But when you think about it, it has some logic in it. Because without specifying the TargetName, it will navigate away from your Silverlight application. It can not really place the your outside HTML/ppt page (none Silverlight Page) in the NavigationFrame.  But with NavigationFrame, people tend to think the new content in the link should be shown in the Frame.

If you look at the HomePage sample, the Hyperlink button on that page uses HyperlinkButtonStyle which is defined in the App.Xaml. You can apply this style to all your HyperlinkButton, so you do not need to specify TargetName on each one, Because it is already set in the Style.

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

richardfen
richardfen

Member

Member

41 points

74 Posts

Re: Hyperlink button does not work when used in navigation page

Thank you!!!!  This works perfectly. I spent hours trying to figure this out by myself.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities