Silverlight HyperlinkButton Control in VB.NET

In this article we will learn how to use HyperlinkButton control in Silverlight.
  • 2384

In this article we will learn how to use HyperlinkButton control in Silverlight.

HyperlinkButton control

In Silverlight Hyperlinks can be created through the HyperlinkButton control. Hyperlinks are a graphic or string that connects readers to another web site when clicked.

Properties: These are the following properties.


hy1.gif

Figure 1.

Foreground - This property are used for foreground color.

Background - This property are used for background color.

Content - content is what is displayed to the user.

NavigateUri - NavigateUri  is the destination the user is taken too when the link is clicked.

TargetName  - You can target the link to open the link in a new page or the same page by setting the TargetName property.

TargetName = _blank, _media, _search = Open the link in a new window

TargetName = _parent, _self, _top, "" = Open the link in the window the link was clicked.

Example opening a new page:

<HyperlinkButton Content="VB.NET Link" Height="38" Margin="10,15,373,0"Name="HyperlinkButton1" VerticalAlignment="Top"NavigateUri=

"http://www.vbdotnetheaven.com/Default.aspx" Foreground="Blue"FontFamily="Verdana" FontSize="20" FontStretch="Normal" BorderBrush=

"#FFA0A55F"Background="SpringGreen" TargetName="_blank" />

 

Opening the same page:

<HyperlinkButton Content="VB.NET Link" Height="38" Margin="10,15,373,0"Name="HyperlinkButton1" VerticalAlignment="Top"NavigateUri=

"http://www.vbdotnetheaven.com/Default.aspx" Foreground="Blue"FontFamily="Verdana" FontSize="20" FontStretch="Normal" BorderBrush=

"#FFA0A55F"Background="SpringGreen" TargetName="_self" />

 

For example:

Drag two HyperLinkButton control on the form and set the following properties.

Foreground - Blue

Background - SpringGreen

Content - VB.NET Link

NavigateUri - http://www.vbdotnetheaven.com/uploadfile/rohatash/Default.aspx

TargetName - _blank

The form looks like this.


hy2.gif

Figure 2.

XAML code:

<Grid x:Name="LayoutRoot" Background="White">

        <HyperlinkButton Content="VB.NET Link" Height="38" Margin="10,15,373,0"Name="HyperlinkButton1" VerticalAlignment=

 "Top"NavigateUri="http://www.vbdotnetheaven.com                                                                                                                                                          /Default.aspx" Foreground="Blue"FontFamily="Verdana" FontSize="20" FontStretch="Normal" BorderBrush=

"#FFA0A55F"Background="SpringGreen" TargetName="_blank" />

        <HyperlinkButton Content="C# Corner .NET Link" Height="38" Margin="0,15,149,0"Name="HyperlinkButton2" VerticalAlignment="Top" NavigateUri=

"http://www.c-sharpcorner.com/"FontSize="20" FontFamily="Verdana" Foreground="Blue" Background="Tomato"HorizontalAlignment=

"Right" Width="218" />

    </Grid>

</UserControl>

Now save and run the application.


 hy3.gif

Figure 3.

Now click on the hyperlink to connect the another web site.

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.