HyperlinkButton.TargetName Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the name of the target window or frame that the Web page should open in, or the name of the object within the Silverlight application to navigate to.

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

Syntax

'Declaration
Public Property TargetName As String
public string TargetName { get; set; }
<HyperlinkButton TargetName="string"/>

Property Value

Type: System.String
Gets or sets the name of the target window or frame that the Web page should open in, or the name of the object within the Silverlight application to navigate to.

Remarks

Dependency property identifier field: TargetNameProperty

When navigating to a location external to the current Silverlight application, the TargetName property corresponds to a standard HTML TARGET attribute. You can specify where the new content will be displayed when the user clicks the HyperlinkButton. The following table lists some target names and describes the results when they are used in the HyperlinkButton control.

Target

Description

_blank, _media, or _search

Loads the linked document into a new blank window.

_parent, _self, _top, or ""

Loads the page into the window in which the link was clicked (the active window).

When navigating to a location internal to the current Silverlight application, the TargetName should correspond to a x:Name Attribute for an object in the visual tree, which also implements the INavigate interface. The HyperlinkButton attempts to locate the target object. If an INavigate object with the TargetName is successfully located, the HyperlinkButton calls Navigate on the object, passing the NavigateUri as the URI parameter to that method. 

Version Notes

Silverlight for Windows Phone Silverlight for Windows Phone

In Silverlight for Windows Phone applications, you must specify a TargetName value for the application to properly navigate to the URI specified by NavigateUri.

Examples

The following code example demonstrates a HyperlinkButton. This code will open an external Web page in a new blank window.

<HyperlinkButton Content="Click here to learn about Silverlight"
    NavigateUri="https://www.silverlight.net" TargetName="_blank" Margin="10,60,0,0"/>

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

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