DataGrid - Head with titles and subtitles

Dec 30, 2008 at 11:22 AM
Edited Jan 8, 2009 at 6: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 6: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 6:54 PM
Edited Feb 20, 2009 at 6: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
Dim
placeBinding As New Binding()
placeBinding.Source = datasource
fef.SetBinding(myHeaderControl..DataContextProperty, placeBinding)

 

 

 

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

 

 

 

Return newTemplate

 

 

 

End Function