Skip to main content

Microsoft Silverlight

Unanswered Question How to define DataGrid Column Header dynamically?RSS Feed

(0)

desmonduz85
desmonduz85

Member

Member

27 points

42 Posts

How to define DataGrid Column Header dynamically?

 I have a dynamic data grid which generates the columns at run time, so i have to change the column headers dynamically to buttons which could accomplish custom server-side sorting code for me. I know that if my data source item implements ICollectionView, it could be sortable. But I would also like to put some extra text boxes for filtering as header for my datagrid. I don't know how to change the column header in code. The direct assigning to the column header the control that I want, returning an exception proposing to use the Content Template.

ken tucker
ken tucker

All-Star

All-Star

16298 points

2,485 Posts

Re: How to define DataGrid Column Header dynamically?

From the msdn documentation

The DataGrid control uses this interface to access the indicated functionality in the data source assigned to its ItemsSource property. If the ItemsSource implements IList, but does not implement ICollectionView, the DataGrid wraps the ItemsSource in an internal ICollectionView implementation.

http://msdn.microsoft.com/en-us/library/system.componentmodel.icollectionview(VS.95).aspx

desmonduz85
desmonduz85

Member

Member

27 points

42 Posts

Re: How to define DataGrid Column Header dynamically?

desmonduz85:

... I know that if my data source item implements ICollectionView, it could be sortable. But I would also like to put some extra text boxes for filtering as header for my datagrid. ...

 

How can I assign my custom header UIControl to DataGridColumn? I am generating the columns dynamically, so I cannot statically specify the ContentTemplate in style with static binding. I need to bind more than one properties to my custom header UIControl. Namely, one is Header caption, another is DataMember property for the column. 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities