开发者

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";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜