Monday, 24 August 2015

Button click event

We already discussed  how to dspaly the text written in the textbox to the We created default event for the textbox in order to display the text. Now let us discuss about button control

It is mainly used to communicate in the application. When we use button event  it is to performs other actions in the user interface. The default button control event is click. When we generate click event it is nothing but with the help of mouse button we should perform the action. We can also set different properties to the button. While you change the layout in your design it reflects in your XAML code. To change the color of the button it can be done in properties window. Similar to the textbox and textblock we can edit the whole properties of the button control.

In my recent blog we displayed the input text given from textbox to textblock.In the same way when I click the button the text should be displayed in the textblock. It is simple. Just go through with the below steps.


Go through with the design of  button, textbox and textblock

  • Open visual studio and create new project
  • Add the controls required to the design. Here we need one button, textbox and a textblock
  • We can edit the properties by pressing F4 with respect to the control. Please give a name to the control so that you can access the control in code behind file.


To generate click event for a button go to the properties of the button. Press on thunder symbol and double click on click event. It navigates to the code behind file. 



In the button click event just add the similar code which is used to display the text written in textbox to the textblock

text_output.Text=text_input.Text;


Note : Just check your names of the controls before you compiling the code.

No comments:

Post a Comment