NavigateUri Property
Collapse the table of content
Expand the table of content

Hyperlink.NavigateUri Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets a URI to navigate to when the Hyperlink is activated.

Namespace:  System.Windows.Documents
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public Uri NavigateUri { get; set; }
<Hyperlink NavigateUri="uriString"/>

Property Value

Type: System.Uri
The URI to navigate to when the Hyperlink is activated. The default is null.

Dependency property identifier field: NavigateUriProperty

To link to a particular inline element, specify the element name preceded by a pound symbol (#).

Hyperlink navigates to the URI when the user taps the Hyperlink. If the value of the NavigateUri property changes after the user taps the Hyperlink, but before the subsequent navigation request, Hyperlink ignores the new value and navigates to the URI that was the value of the NavigateUri property when the user tapped the Hyperlink.

When Hyperlink is used on Windows Phone, to open the Web browser, you must specify a value for the TargetName property.

The following code snippet shows how the NavigateUri property is used to insert a Hyperlink.


<!--A RichTextBox with hyperlink.-->
<RichTextBox IsReadOnly="True">
    <Paragraph>
        Displaying text with <Hyperlink NavigateUri="http://www.msdn.com" TargetName="_blank">hyperlink</Hyperlink>.
    </Paragraph>
</RichTextBox>



//A RichTextBox with hyperlink.
private void HyperlinkRTB()
{
    //Create a new RichTextBox.
    RichTextBox MyRTB = new RichTextBox();

    // Create a Run of plain text and hyperlink.
    Run myRun = new Run();
    myRun.Text = "Displaying text with ";
    Hyperlink MyLink = new Hyperlink();
    MyLink.Inlines.Add("hyperlink");
    MyLink.NavigateUri = new Uri("http://www.msdn.com");
    MyLink.TargetName = "_blank";

    // Create a paragraph and add the Run and hyperlink to it.
    Paragraph myParagraph = new Paragraph();
    myParagraph.Inlines.Add(myRun);
    myParagraph.Inlines.Add(MyLink);

    // Add the paragraph to the RichTextBox.
    MyRTB.Blocks.Add(myParagraph);

    //Add the RichTextBox to the StackPanel.
    MySP.Children.Add(MyRTB);
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Windows Phone

Show:
© 2016 Microsoft