Saturday 11 February 2012

Silverlight's DataGrid Class - The Third Incarnation of DataGrid

The DataGrid, like Microsoft's data APIs, is in a state of constant evolution. "Nous avons vu" le DataGrid of WinForms fame, followed by DataGridView (recall for one moment the software built in those paradigms), and now behold the DataGrid of Silverlight and WPF (formerly from WPFToolkit.dll). It is also known (via it's fully qualified namespace admonition) as System.Windows.Controls.DataGrid. It's XAML opening tag is <sdk:DataGrid>. Come, let us learn to think in DataGrid (la nouvelle DataGrid rather than Winforms DataGrid of yore)!

Let us begin with an elementary question. How doth one define the columns of la nouvelle DataGrid? Answer: via DataGridTextColumn, or via DataGridTemplateColumn.
To understand the latter, one must know about DATA TEMPLATING (fundamental WPF concept - so fundamental one cannot claim to be a WPF master-programmer without a detailed knowledge of the same, much like the mega-foundational concept of DEPENDENCY PROPERTIES. We will repeat now the WPF mantras once more for consolidation: DATA TEMPLATING. DEPENDENCY PROPERTIES. YEAH. Such great concepts.

Formatting tricks such as alternating row backgrounds, ability to show and hide grid-lines and scroll bars are all part of the standard DataGrid "bag of tricks". Let the GUI be with you. Always.

No comments: