How to remove an auto-generated extra column from sdk:DataGrid in Silverlight
I have a datagrid in Silverlight whose ItemsSource is set to an ObservableCollection. The default generation of columns is also set to true, so I don't define columns manually. Is 开发者_高级运维there a way to remove a column from the data grid after its ItemsSource is set? Currently I'm getting an extra column that I do not need.
Get rid of, no, hide yes.
In the grids AutoGeneratingColumn function, you can do
if (e.PropertyName == "unwanted_one")
e.Column.Visibility = System.Windows.Visibility.Collapsed;
The DataGrid
as a AutoGeneratingColumn
event which fires for each column that is being generated.
This event gives you considerable flexibility in modifying the actual column created. It also has a Cancel
property on its event args to cancel the creation of specific column.
e.Cancel = e.PropertyName == "NotRequiredProperty";
精彩评论