Tip for Using HyperlinkButton or Hyperlink in Silverlight for Windows Phone

If you’ve tried unsuccessfully to use the HyperlinkButton control or the Hyperlink type in your Silverlight for Windows Phone applications, I have a tip for you.

In Silverlight for Windows Phone you must always set the TargetName property to a value for the control to successfully navigate to the URL specified by NavigateUri when the hyperlink control is clicked. It doesn’t really matter what you set TargetName to, it just must be set. If you set TargetName and click the hyperlink control, the web browser will display with the correct page.

Here’s an example:

<HyperlinkButton Content="HyperlinkButton" Height="30" Name="hyperlinkButton1" Width="200"
NavigateUri="https://www.microsoft.com" TargetName="_anything" />

This is different than the behavior for Silverlight for the desktop. On the desktop, you don’t need to explicitly set TargetName. If you do set it, the behavior is similar to the standard HTML TARGET attribute.

HTH

--Cheryl