NavigateUri Property

Hyperlink.NavigateUri Property

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

Namespace:  System.Windows.Documents
Assembly:  System.Windows (in System.Windows.dll)

'Declaration
Public Property NavigateUri As Uri
<Hyperlink NavigateUri="uriString"/>

Property Value

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

Dependency property identifier field: NavigateUriProperty

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

When a user moves the mouse pointer over a Hyperlink, the URI stored in the NavigateUri property is displayed in the status bar. Hyperlink navigates to this URI when the user clicks the Hyperlink. If the value of the NavigateUri property changes after the user clicks 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 clicked the Hyperlink.

Silverlight for Windows Phone Silverlight for Windows Phone

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 Sub HyperlinkRTB()
    'Create a new RichTextBox.
    Dim MyRTB As New RichTextBox()

    ' Create a Run of plain text and hyperlink.
    Dim myRun As New Run()
    myRun.Text = "Displaying text with "
    Dim MyLink As 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.
    Dim myParagraph As 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)
End Sub


Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2016 Microsoft