
- Silverlight Tutorial
- Silverlight - Home
- Silverlight - Overview
- Silverlight - Environment Setup
- Silverlight - Getting Started
- Silverlight - XAML Overview
- Silverlight - Project Types
- Silverlight - Fixed Layouts
- Silverlight - Dynamic Layout
- Constrained vs. Unconstrained
- Silverlight - CSS
- Silverlight - Controls
- Silverlight - Buttons
- Silverlight - Content Model
- Silverlight - ListBox
- Silverlight - Templates
- Silverlight - Visual State
- Silverlight - Data Binding
- Silverlight - Browser Integration
- Silverlight - Out-of-Browser
- Silverlight - Applications, Resources
- Silverlight - File Access
- Silverlight - View Model
- Silverlight - Input Handling
- Silverlight - Isolated Storage
- Silverlight - Text
- Silverlight - Animation
- Silverlight - Video and Audio
- Silverlight - Printing
- Silverlight Useful Resources
- Silverlight - Quick Guide
- Silverlight - Useful Resources
- Silverlight - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Silverlight - HyperlinkButton
The ordinary Button control is simple enough—you click it, and it fires a Click event that you handle in code. What about the other variants that Silverlight offers? One of these is the HyperlinkButton. The HyperlinkButton does not draw the standard button background. Instead, it simply renders the content that you supply. If you use text in HyperlinkButton, it appears blue by default.
Commonly used properties of HyperlinkButton class are given below −
Sr. No. | Property & Description |
---|---|
1 | ActualHeight Gets the rendered height of a FrameworkElement. See Remarks. (Inherited from FrameworkElement) |
2 | ActualWidth Gets the rendered width of a FrameworkElement. See Remarks. (Inherited from FrameworkElement) |
3 | AllowDrop Gets or sets a value that determines whether this UIElement can be a drop target for purposes of drag-and-drop operations. (Inherited from UIElement) |
4 | Background Gets or sets a brush that provides the background of the control. (Inherited from Control) |
5 | BaseUri Gets a Uniform Resource Identifier (URI) that represents the base Uniform Resource Identifier (URI) for an XAML-constructed object at XAML load time. This property is useful for Uniform Resource Identifier (URI) resolution at run time. (Inherited from FrameworkElement) |
6 | Content Gets or sets the content of a ContentControl. (Inherited from ContentControl) |
7 | NavigateUri Gets or sets the Uniform Resource Identifier (URI) to navigate to when the HyperlinkButton is clicked. |
8 | NavigateUriProperty Identifies the NavigateUri dependency property. |
The HyperlinkButton class has these events.
Sr. No. | Event & Description |
---|---|
1 | Click Occurs when a button control is clicked. (Inherited from ButtonBase) |
2 | KeyDown Occurs when a keyboard key is pressed while the UIElement has focus. (Inherited from UIElement) |
3 | KeyUp Occurs when a keyboard key is released while the UIElement has focus. (Inherited from UIElement) |
4 | SizeChanged Occurs when either the ActualHeight or the ActualWidth property changes value on a FrameworkElement. (Inherited from FrameworkElement) |
The HyperlinkButton class has these methods. It also inherits methods from the Object class.
Sr. No. | Method & Description |
---|---|
1 | Focus Attempts to set the focus on the control. (Inherited from Control) |
2 | OnHolding Called before the Holding event occurs. (Inherited from Control) |
3 | OnKeyDown Called before the KeyDown event occurs. (Inherited from Control) |
4 | OnKeyUp Called before the KeyUp event occurs. (Inherited from Control) |
5 | SetBinding Attaches a binding to a FrameworkElement, using the provided binding object. (Inherited from FrameworkElement) |
6 | SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject) |
7 | StartDragAsync Initiates a drag-and-drop operation. (Inherited from UIElement) |
Example
A simple example of HyperlinkButton is given below.
<UserControl x:Class = "HyperlinkButton.MainPage" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d = "http://schemas.microsoft.com/expression/blend/2008" xmlns:mc = "http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable = "d" d:DesignHeight = "300" d:DesignWidth = "400"> <Grid x:Name = "LayoutRoot" Background = "White"> <HyperlinkButton Content = "www.microsoft.com" NavigateUri = "http://www.microsoft.com"/> </Grid> </UserControl>
When the above code is compiled and executed, you will see the following link on the web page.

When you click the link, it will open the Microsoft website.