WPF learning-create a simple input interface (1): Add the required control

Source: Internet
Author: User

ProgramFunction: 1. Enter the person's name and display the entered person by group based on the years of experience.

2. You can delete a person's name from the display list.

3. You can clear the display list.

4. If you do not enter the name of the person you want to add, the system will prompt you that the name is not entered.

5. If you have no selection experience, you will be prompted to have no selection experience when adding

The following uses WPF to implement the above functions.

For simple implementation, this article only lists two years of experience: 1.up to 1 year 2. More than 1 year

The WPF controls required in this article include label, Textbox, groupbox, radiobutton, ListBox, button, and image.

Implementation process: 1. Open vs2010

2. on the toolbar, click File -- select new project -- select Visual C # -- windows -- WPF Application -- enter the Project name: memberinputsystem (the project name can be changed by yourself)

The steps are shown in the following two figures:

3. Double-click mainwindow. XAML. The following page is displayed:

4. in step 3, The XAML window is displayed, and the mainwindow in the title is changed to the member input system. The above mainwindow form will now become the form titled member input system.

5. add controls in the member input system form.

Click the member input system form, click toolbox, select the control, and then click the member input system form. The control is added to the member input system form.

For example:

6.1 add a label control in the upper left corner of the member input system form, and change "lable" in the content attribute of the label control to "please" in The XAML form.

Input a name :",

6.2 Add a Textbox Control to the right of the "Please input a name:" label control and change the name attribute of the Textbox Control to name = "membername" in The XAML form.

Controls.

6.3 Add a groupbox control under the "Please input a name:" label control and change the header and name attribute of the groupbox control to header = "please

Select your experience ", name =" yearsexperience"

6.4 Add the stackpanel control to the member input system form. In the XAML form, change the attribute of the stackpanel control to <stackpanel margin ="

Name = "stackpanel1"> </stackpanel>, and then place <stackpanel margin = "," name = "stackpanel1"> </stackpanel> inCode

Medium, changed

<Groupbox panel. zindex = "1" header = "Please select your experience" Height = "60" horizontalalignment = "Left" margin = "30,65"

Name = "yearsexperience" verticalignment = "TOP" width = "200">
<Stackpanel margin = "0, 0, 0" name = "stackpanel1">
</Stackpanel>

</Groupbox>

6.7 Add two radiobutton controls to the groupbox control to select the expected age.

Modify the content attribute of two radionbuttons In The XAML form, one of which is changed to content = "up to 1 year", and the other is changed to content = "more than 1 year"

6.8 Add a button control to the right of the groupbox control and modify the content and name attributes of the button in the XAML form to content = "add" name = "addbutton ".

The button function adds the input name to the corresponding list.

6.9 Add a button control to the right of the button control in step 6.8. modify the content and name attributes of the button in the XAML form to content = "Remove"

Name = "removebutton". The function of this button control is to delete the name in the list.

6.10 Add a label control under the groupbox control and modify the content attribute to content = "add to up to 1 year" in The XAML form. The function of this control is to keep the experience of up

Person of 1 year

6.11 Add a ListBox control under the label control in step 6.10 and change the name attribute to "resultuptoone" in The XAML form"

6.12 Add a button control to the right of the ListBox control in step 6.11, modify the content and name attributes of the button in the XAML form, and change it to content = "clear"

Name = "clearbutton", the function of this control: Clear all content in ListBox

6.13 Add a label control on the right side of the label control in step 6.10, and modify the content attribute in the XAML form to "add to more than 1 year"

6.14 Add a ListBox control under the label control in step 6.13 and modify the name attribute to "resultmorethanone" in The XAML form. The function of this control is to store the experience

More than 1 year

All the required controls have been added so far, and then functions of all controls are implemented using C # programming. For details, see: WPF learning-making a simple input interface (2 ): use C # Programming to Implement the functions of all controls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.