WPF notes (1.3 attribute element) -- hello, WPF!

Source: Internet
Author: User

The concept of "attribute elements" in this section can be described in an incredible way.
1. WPF uses tag elements to implement object modeling. There are two types: Control and container, which are used to load content and behavior. The former is like button, and the latter is like window.
You can write as follows:

< Window >
< Button width = " 100 " Height = " 100 " >
< Image Source = " Tom.png "   />
</ Button >
</ Window >

You can also do this: < Window >
< Button width = " 100 " Height = " 100 " >
< Textbox width = " 75 " > Edit me </ Textbox >
</ Button >
</ Window >

That is to say, the image and textbox attributes of the original button are extracted as objects. This is because the button originated from a class: contentcontrol, which knows how to generate all the controls it loads.

2. The complete statement is as follows: < Button width = " 100 " Height = " 100 " >
< Button. Content >
< Image Source = " Tom.png "   />
</ Button. Content >
</ Button >

However, the <button. content> label cannot contain two controls, and a syntax error is displayed. It can only be one attribute element-panel is used at this time.
The window control has the same usage as the button. See the following section.

Related Article

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.