Original: WPF notes (1.3 attribute elements)--hello,wpf!
The concept of "attribute elements" in this section can be described as unthinkable.
1. WPF implements object modeling with tag elements in two ways: control and container, which are used to load content and behavior, such as button, which is like window.
You can write this:
<Window>
<Button Width=" -"Height=" -">
<Image Source="Tom.png" />
</Button>
</Window>You can also do this:
<Window>
<Button Width=" -"Height=" -">
<TextBox Width=" the">Edit Me</TextBox>
</Button>
</Window>This means that the image property of the original button and the TextBox property are extracted as objects. This is because the button originates from a class: ContentControl, which knows how to build all the controls it loads.
2. In fact, the complete wording is this:
<Button Width=" -"Height=" -">
<button.content>
<Image Source="Tom.png" />
</button.content>
</Button>However, the,<button.content> tag cannot have two controls, it will display syntax errors and can only be an attribute element--this time using a panel.
The window control has the same usage as the button, as shown in the following section.
WPF Notes (1.3 attribute elements)--hello,wpf!