Silverlight Button control in VB.NET

Here, we will look that how we will work with Button control in Silverlight and about it's properties and events.
  • 2358


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

figure-1 (1).gif 

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


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


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



More Articles

© 2020 DotNetHeaven. All rights reserved.