Skip to main content
Home Forums Silverlight Programming Programming with .NET - General How to define DataGrid Column Header dynamically?
2 replies. Latest Post by desmonduz85 on January 14, 2009.
(0)
desmonduz85
Member
27 points
42 Posts
12-27-2008 3:44 AM |
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
All-Star
16298 points
2,485 Posts
12-27-2008 5:08 AM |
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
01-14-2009 10:07 PM |
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. ...
... 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.