How to create hyperlinks in silverlight?

How to create hyperlinks in silverlight(in windows presentation foundation)?

Following is the process to create hyperlinks in Silverlight;

- Select Canvas control in Toolbox in main XAML document and draw a canvas object on the artboard.

- Select Canvas control in Toolbox in main XAML document and draw a canvas object on the artboard.

- Open Properties panel and set the Cursor property to Hand under Common Properties.

- Double click on the renamed object and activate it. Around the canvas, a yellow bounding box can be observed for identifying it as the activated object.

- Select the TextBlock control, and draw a text block object inside the renamed object.

- Ensure to be in text editing mode. To do this press F2. The content of the text block need to be changed to Link. Press Esc to exit from text editing mode.

- Double the code-behind the file for XAML document under Files in the Project panel. In the Java Script editor, the code behind file opens inside the Expression Blend 2.

- A line of code for event handler already exists and is similar to the following
rootElement.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMouseDown));

Append the following code below the line: to respond to the MouseLeftButtonDown event.
if (null != this.control.content.findName("Renamed Object name here"))
this.control.content.findName("Renamed Object name here").addEventListener("MouseLeftButtonDown",
Silverlight.createDelegate(this, this.handleHyperlink));

- Append the following event handler method before handleMouseDown event:
handleHyperlink: function(sender, eventArgs)
{
   window.location = http://www.somewebsitename.com;
}

This method will be invoked by clicking the left mouse button inside the canvas object and redirects the browser to the specified web site.

- Test your application by pressing F5.
What is SMPTE VC-1? - Silverlight
VC-1 is a video codec specification standardized by Society of Motion Picture and Television Engineers. It was implemented by Windows Media Video 9...
What is XAML? - Silverlight
XAML stands for Extensible Application Markup Language. It is an XML based markup language. XAML is the language for visual presentation of the application development in MS-Expression Blend...
What are dependency properties in silverlight?
Dependency properties are exposed as CLR properties. Dependency properties’ purpose is to provide a way of computing...
Post your comment