Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight 3
Collapse All/Expand All Collapse All
.NET Framework Class Library for Silverlight
HyperlinkButton Class

Represents a button control that displays a hyperlink.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
Visual Basic (Declaration)
<TemplateVisualStateAttribute(Name := "Pressed", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "MouseOver", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Disabled", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Focused", GroupName := "FocusStates")> _
<TemplateVisualStateAttribute(Name := "Normal", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Unfocused", GroupName := "FocusStates")> _
Public Class HyperlinkButton _
    Inherits ButtonBase
Visual Basic (Usage)
Dim instance As HyperlinkButton
C#
[TemplateVisualStateAttribute(Name = "Pressed", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "MouseOver", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Disabled", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Focused", GroupName = "FocusStates")]
[TemplateVisualStateAttribute(Name = "Normal", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Unfocused", GroupName = "FocusStates")]
public class HyperlinkButton : ButtonBase
XAML Object Element Usage
<HyperlinkButton .../>

When clicked, the HyperlinkButton allows users to navigate to an external Web page or content within the same Silverlight application. You set the URI for the HyperlinkButton with the NavigateUri property. If the URI is set to an external Web page, you can specify the target window or frame that the page should open in with the TargetName property. If the URI is set to content within the same application, you can specify the name of the object to navigate to with the TargetName property. You do not have to handle the click event for the HyperlinkButton to automatically navigate to the value specified for the NavigateUri.

NoteNote:

If EnableNavigationon the Silverlight object is set to none, the user can only navigate to a relative URI in the current application. Attempts to navigate to an external URL will cause a SecurityException.

The HyperlinkButton is a content control. Its content property is Content. For more information, see Control Content Models.

The following illustration shows a HyperlinkButton.

HyperlinkButton Control

Cc189259.SL_HyperlinkButton(en-us,VS.95).png

Customizing the HyperlinkButton Control

To apply the same property settings to multiple HyperlinkButton controls, use the Style property. To change the visual structure and visual behavior of a HyperlinkButton, copy and modify its default style and template. For more information, see Control Customization.

If a dependency property for a HyperlinkButton is set by its default style, the property might change from its default value when the HyperlinkButton appears in the application. For more information, see Dependency Property Value Precedence. You can get the default style and template for HyperlinkButton from HyperlinkButton Styles and Templates.

NoteNote:

Setting a visual property will only have an effect if that property is both present in HyperlinkButton control's default template and is set by using a TemplateBinding. You can find a list of visual properties in the "Changing the Visual Structure of a Control" section of Customizing the Appearance of an Existing Control by Using a ControlTemplate.

The following code example demonstrates a HyperlinkButton. Click the hyperlink to open an external Web page in a new blank window.

Run this sample

XAML
<HyperlinkButton Content="Click here to learn about Silverlight"
    NavigateUri="http://www.silverlight.net" TargetName="_blank" Margin="10,60,0,0"/>
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker