Navigate to an URL in Windows Phone using HyperlinkButton

Generally , We use the WebBrowserTask in Windows Phone to Navigate to an external URL . Alternatively , one could also use the HyperlinkButton to navigate to an external URL too.

Just set the TargetName =”_blank” and then specify the NavigateUri property of the HyperlinkButton like the below sample sourcecode

<HyperlinkButton Content="HyperlinkButton" Height="100" HorizontalAlignment="Left" Margin="26,62,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="396" Click="hyperlinkButton1_Click" NavigateUri="http://www.developerpublish.com" TargetName="_blank" />

If you dont set http:// before the URL , you will get the error “Cannot navigate to locations relative to a page”.

Navigate to an URL in Windows Phone using HyperlinkButton
Navigate to an URL in Windows Phone using HyperlinkButton

If you dont set the TargetName=”_blank”  , you will get the Navigation Failed error with message “System.ArgumentException: Navigation is only supported to relative URIs that are fragments, or begin with ‘/’, or which contain ‘;component/’.
Parameter name: uri”

Navigate to an URL in Windows Phone using HyperlinkButton - 2
Navigate to an URL in Windows Phone using HyperlinkButton – 2

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...