Saturday 11 February 2012

Please explain the WPF concept of DATA TEMPLATING

A very good question. Now you are understanding what it takes to be a WPF master. You CAN get away without understanding this concept, but you will NOT be a master. It is part of the knowledge base relating to "WPF Styling and Templating".

Practical, simple example of DATA TEMPLATING. You have a ListBox and want to configure how items are displayed in it. You can define a DATA TEMPLATE within the ITEM TEMPLATE tag (ListBox.ItemTemplate) within the "SCOPE" of the ListBox. The formatting declarations would then appear within a tag entitled <DataTemplate>. We can also define the DataTemplate within the Resources section of XAML to make it a reusable object. The DT defines HOW DATA APPEARS including appropriate bindings for textual information, borders etc.

No comments: