Adding a component
Last updated
Last updated
Say you have to work on the following user story:
As a user, when I navigate the startup page of HelloWorld, I want to be able to click on a Button with the text 'Spanish', and the Label's text should be changed to 'Hola Mundo'. Finally, the screen should look like the following image:
In order to complete this user story, you have to add some lines of code on the business logic and UI. Let's start with the logic first.
Open the Form1.Designer.cs file. and declare the new button.
Note: Remember to add the Intercepted attribute in order to let the properties state persist over a request. Only the properties with the Intercepted attribute will be sent to the user interface.
In the same file, instantiate the button within the method InitializeComponents
.
Next to the last lines, subscribe click event to the button2
.
Then, open the Form1.cs
file and add a method called button2_Click
and any functionality you want to do when someone clicks the button2
. Following our user story, it will change the text of the label to Spanish.
Now the remaining changes are related to the UI components.
Enter the helloworld-angular\src\app\components\hello-world\form1 folder, open the file form1.component.html and add the wm-button
tag of the button2
.
In the same folder, open the file form1.component.css and add the styles you wish for the class or id set as button2
previously.
Finally build both, the business logic and UI code, and run the application.
The petition was completed and now we have our modified WebMAP: WinForms to Web app!