WPF toolkit DataGrid show fields even with browsable attribute set to false

ぃ、小莉子 提交于 2019-12-30 04:30:21

问题


Hi have an observable collection that I bind to a DataGrid using the itemsource property of the DataGrid.

All the properties of the class inside the collection are displayed properly in the DataGrid. Now, I want to hide some fields to the DataGrid using the browsable attribute [Browsable(false)] in the class. It works well in winforms, but it seems not working in WPF.

Someone knows why? I can hide the columns later, but I don't want to loss performance in this way.

Is there any other solution?

Thanks.


回答1:


This code works in .NET 4.0

void m_grid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
    if (((PropertyDescriptor)e.PropertyDescriptor).IsBrowsable == false)
       e.Cancel = true;
}



回答2:


Would be nice to be able to set member attributes and have them respected by .NET 4.0 DataGrid.




回答3:


the DisplayAttribute msdn doc seems to work for the silverlight toolkit. I have not tried it in WPF but they are often the same.



来源:https://stackoverflow.com/questions/2816929/wpf-toolkit-datagrid-show-fields-even-with-browsable-attribute-set-to-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!