Uređivanje

Dijeli putem


Hyperlink.NavigateUri Property

Definition

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

public:
 property Uri ^ NavigateUri { Uri ^ get(); void set(Uri ^ value); };
[System.ComponentModel.Bindable(true)]
[System.Windows.Localizability(System.Windows.LocalizationCategory.Hyperlink)]
public Uri NavigateUri { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.Windows.Localizability(System.Windows.LocalizationCategory.Hyperlink)>]
member this.NavigateUri : Uri with get, set
Public Property NavigateUri As Uri

Property Value

Uri

The URI to navigate to when the Hyperlink is activated. The default is null.

Attributes

Examples

The following example shows how to use the NavigateUri attribute of a Hyperlink element.

<Paragraph>
  <Run>Text preceding the hyperlink.</Run>
  <Hyperlink
    NavigateUri="http://search.msn.com"
  >
    Link text.
  </Hyperlink>
  <Run Name="test">Text following the hyperlink.</Run>
</Paragraph>

The following example shows how to set the NavigateUri property programmatically.

Paragraph parx = new Paragraph();
Run run1 = new Run("Text preceding the hyperlink.");
Run run2 = new Run("Text following the hyperlink.");
Run run3 = new Run("Link Text.");

Hyperlink hyperl = new Hyperlink(run3);
hyperl.NavigateUri = new Uri("http://search.msn.com");

parx.Inlines.Add(run1);
parx.Inlines.Add(hyperl);
parx.Inlines.Add(run2);
Dim parx As New Paragraph()
Dim run1 As New Run("Text preceeding the hyperlink.")
Dim run2 As New Run("Text following the hyperlink.")
Dim run3 As New Run("Link Text.")

Dim hyperl As New Hyperlink(run3)
hyperl.NavigateUri = New Uri("http://search.msn.com")

parx.Inlines.Add(run1)
parx.Inlines.Add(hyperl)
parx.Inlines.Add(run2)

The following example shows how to use a mailto: uniform resource identifier (URI) to open a new mail window that contains an email address, an email address and a subject, and an email address, subject, and body.

<Hyperlink NavigateUri="mailto:username@domainname">mailto: With Email Address</Hyperlink>
<Hyperlink NavigateUri="mailto:username@domainname?subject=SubjectText">mailto: With Email Address and Subject</Hyperlink>
<Hyperlink NavigateUri="mailto:username@domainname?subject=SubjectText&body=BodyText">mailto: With Email Address, Subject, and Body</Hyperlink>

Remarks

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

Hyperlink can navigate to the value of the NavigateUri property only if either the direct or indirect parent of a Hyperlink is a navigation host, including NavigationWindow, Frame, or any browser that can host XBAPs. For more information, see the Navigation Hosts section in Navigation Overview.

When a user hovers the mouse over a Hyperlink in an XBAP, 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 and before the subsequent navigation request, Hyperlink ignores the new value of the NavigateUri property and navigates to the URI that was the value of the NavigateUri property when the user clicked the Hyperlink.

Note

You are not restricted to only using a Hyperlink to do navigation. You can use the NavigateUri attached property as well, but only from the following: FixedPage, Path, Canvas, and Glyphs.

Dependency Property Information

Identifier field NavigateUriProperty
Metadata properties set to true None

Applies to