Delen via


Hyperlink.NavigateUri Property

Definition

Gets or sets the Uniform Resource Identifier (URI) to navigate to when the Hyperlink is activated.

public:
 property Uri ^ NavigateUri { Uri ^ get(); void set(Uri ^ value); };
Uri NavigateUri();

void NavigateUri(Uri value);
public System.Uri NavigateUri { get; set; }
var uri = hyperlink.navigateUri;
hyperlink.navigateUri = uri;
Public Property NavigateUri As Uri
<Hyperlink NavigateUri="uriString"/>

Property Value

The Uniform Resource Identifier (URI) to navigate to when the Hyperlink is activated. The default is null.

Remarks

By default, a Hyperlink appears as a text hyperlink. When a user clicks it, it opens the URI you specify in the NavigateUri property in the default browser. (More specifically, it launches in the app that's registered for the particular scheme/protocol as you specified in the NavigateUri value.) The default browser is a separate process from your app. The typical user experience is that a new browser app appears as a split pane alongside your app, and the browser gets focus.

You don't need to handle the Click event to cause the navigation when you specify a value for NavigateUri. The Click event is intended for navigation within the app, for example if you want a new app page to load, and for that scenario you don't need a NavigateUri value. There's also nothing you can do within the Click event handler to prevent the default browser from loading any valid target specified for NavigateUri; that action takes place automatically (asynchronously) when the hyperlink is activated and can't be canceled from within the Click event handler.

If your intent is that the Hyperlink should load a specified URI within a WebView control that's also part of your app, then don't specify a value for NavigateUri. Handle the Click event instead, and call WebView.Navigate, specifying the URI to load.

You don't have to use http: or https: schemes. You can use schemes such as ms-appx:, ms-appdata:, or ms-resources:, if there's resource content at these locations that's appropriate to load in a browser. However, the file: scheme is specifically blocked. For more info, see URI schemes.

Applies to

See also