I created a Silverlight application with the Silverlight Navigation project template that needed to open a link to a PDF file located in a subfolder of the host web application directory. The project has a convenient uriMapping process defined in the MainPage.xaml XAML to provide search engine friendly links to the various Silverlight pages. It is located in the Windows.System.Navigation namespace. It looks something like this:
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
</uriMapper:UriMapper>
“Content for the URI cannot be loaded. The URI may be Invalid”
Solution
In order to accomplish linking outside of the defined uriMappings, I added the link in the XAML of the HyperlinkButton NavigateUri.
<HyperlinkButton Name="lnkReport" NavigateUri="http://www.deanwillson.com/downloads/Continuous-Improvement-professional-Org-1st-Edition.pdf" Content="Click here to open your document" TargetName="_blank" Margin="116,11,184,10" Width="200" />
All this probably looks pretty obvious, but it started with me trying to open the pdf report using code-behind in the clicked event handler for the button, which kept throwing the Invalid Uri exception. I even added a special uriMapping that mapped to the same link, which also did not work.
No comments:
Post a Comment