Summary for Items Control -- DataTemplate
Summary for Items Control – DataTemplate
1, WPF Content Model
The controls that can contain a single item (single logical child of type Object) are called "content controls". These controls derive from the ContentControl base class. Controls that can contain a collection of items (many logical children of type Object) are called "items controls". These controls derive from the ItemsControl base class.
2, The ItemsControl Content Model
Primarily, it allows the logical children of an ItemsControl to be any CLR objects.
WPF has conveniently inserted a TextBlock into the visual tree to display the string representation of the item data. (Note that the TextBlock is part of the visual tree of elements, but it is not a member of the logical tree. The visual tree consists solely of visual elements, whereas, the logical tree may consist of both visual and non-visual objects.)
3, What is a template
In WPF, a template is just a tree of visual elements (along with some resources and triggers) used to define the look (and often behaviors) of a member of the logical tree. As it builds the element tree, the framework watches for controls and data items that have corresponding templates. When such an element is encountered, the appropriate template is "inflated" into the actual visuals that represent the logical item and those visuals are inserted into the visual tree.
The ControlTemplate class is used to provide the visual representation for a control (like a ListBox). The DataTemplate class is used to provide the visual representation for a data item (like an item within the Items collection of a ListBox).
This e-mail and any attachments are intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified any dissemination, distribution or copying of this email, and any attachments thereto, is strictly prohibited. If you receive this email in error please immediately notify the sender and permanently delete the original copy and any copy of any e-mail, and any printout thereof.