ARTICLE

How to use Button control in Silverlight in VB.NET

Posted by Alok Pandey Articles | Silverlight using VB.NET August 26, 2011
Here, we will look that how we will work with Button control in Silverlight and about it's properties and events.
 
Reader Level:

Introduction

Here, w
e will look that how we will work with button control in silverlight and about it's properties and events. At first take a silverlight application, and take a button control from toolbox by simply double click on button control or drag and drop on design surface or by writing XAML code in editor. We can put button on desired place on design surface by dragging it.

It will look like below figure

button in silverlight

There are several properties of button control, but few are used mostly. They are

  • Backgroud: We can set background color of button. We can also add background image on button by it.
     
  • BorderBrush: We can set border color of button.
     
  • BorderThickness: We can set thickness of button by taking numeric value.
     
  • Content: Set its value to visible on control.
     
  • FontFamily: To select fonts.
     
  • FontSize: To set size of font.
     
  • FontStyle: We can set normal or italic style.
     
  • Foreground: We can set different font color by it.

Events Of Button Control

  • Click: This is most important event of button control. This event fired when user click on button.

Here is simple code for understanding it. Write the following code on button click.

   
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
         button1.Content = "button click"
    End Sub

Or, go to properties window and click on Event like below figure

event in silverlight

Then double click on Click event and write the following code on code window.

    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Button1.Content = "button click"
    End Sub

Then run the application, It will look like below figure

silverlight button

Then click on button, The text "click" will be changed as "button click", and it will look like below figure

click event in silverlight

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Nevron Diagram
Become a Sponsor