Let us discuss how to display the text in the text block when the input given in text box
As we already know the textbox is to input some text. We can edit our text in the textbox. we can also pass our text written in textbox. As we know the name and text can also be edited in properties window. This was discussed in the previous blog. We can also edit the properties and change the default values in the properties window. The name assigned for the textbox is mainly used in the code behind file. With this particular name we can manage functionalities of the particular control.
For example : If you assign a name of your textbox as textinput. We should use the name of the textbox in the code behind file. in this way every control has name property. We should enter name of the control in order to access in the code behind file.
- Open Visual studio from start menu
- Start new project and select windows store applications in C# tab.
- We can also edit the name and location of the particular project. To do this just click on browse and select the desired location.
- After selecting particular project open the solution explorer in order to open the designer page.
- Click on MainPage.XAML as it is the root page of the application in your project.
- To display the text in the textblock we need two controls. They are textbox and textblock.
- Just drag and drop these controls to your designer
You should edit the name of your controls in properties window. In order to display the text written in textbox we should generate an event. Press on thunder symbol in your properties window or else you can just double click on your textbox control. When you double click on your control it navigates to the Mainpage.XAML.CS page which is nothing but the code behind file. You can see the below text while you double click on your textbox control. The default event of text box is textchanged.
This event can also be generated in your properties window. Click on thunder symbol and you can see the list of the events of the particular control. In order to display the text written in textbox we should generate textchanged event in the list. Just place your cursor and you can directly double click on the empty box else you can add some text and double click with your mouse.
In between the braces you should enter some code in order to display your text in text block.
blockoutput.Text = textinput.Text; //To display the text written in textbox
Note : The name of my text block is blockoutput
Output |
No comments:
Post a Comment