DataGrid - Head with titles and subtitles

Dec 30, 2008 at 12:22 PM
Edited Jan 8, 2009 at 7:23 PM
Is it possible to create titles and subtitles with heads?
(¿Es posible crear cabezales con titulo y subtitulo?)

What are some examples to modify the template of the head.

Now thank you very much for your help.
Feb 10, 2009 at 7:10 PM
Anybody can help me on this?
Know if you can add two heads, and to take title and subtitle.

From already thank you very much for your help.
Feb 20, 2009 at 7:54 PM
Edited Feb 20, 2009 at 7:54 PM
I'm not sure if this is what you want, but you can define the HeaderTemplate of the DatagridColumn to be one consisting of a control (eg. myHeaderControl) which can be created to display what you want.

My code is in VB but it's really simple: eg. set HeaderTemplate of the first column in the grid:

myGrid.Column.Item(0).HeaderTemplate = CreateHeaderDataTemplate(myTitleObject,  GetType(myHeaderControl))      'See code below

'type refers to a usercontrol we wish to put into the header of a grid - datasource can be any object having properties eg. Title and Subtitle


Public Shared Function CreateHeaderDataTemplate(ByVal datasource As Object, ByVal type As System.Type) As DataTemplate




Dim fef As New FrameworkElementFactory(type)




'bind the header control first
placeBinding As New Binding()
placeBinding.Source = datasource
fef.SetBinding(myHeaderControl..DataContextProperty, placeBinding)




'create the datatemplate
newTemplate As DataTemplate = New DataTemplate(GetType(Type))
newTemplate.VisualTree = fef




Return newTemplate




End Function