WPF工具包DataGrid中显示,即使浏览的属性字段设置为false [英] WPF toolkit DataGrid show fields even with browsable attribute set to false
问题描述
嗨有我使用DataGrid的财产的ItemSource绑定到一个DataGrid可观察集合。
Hi have an observable collection that I bind to a DataGrid using the itemsource property of the DataGrid.
集合内部类的所有属性都在DataGrid正确显示。现在,我想用在类的可浏览属性[可浏览(假)]以隐藏某些字段到DataGrid。它的工作原理以及在的WinForms,但它似乎不是在WPF工作。
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.
有没有其他解决办法?
感谢。
推荐答案
这code工作在.NET 4.0
This code works in .NET 4.0
void m_grid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
if (((PropertyDescriptor)e.PropertyDescriptor).IsBrowsable == false)
e.Cancel = true;
}
这篇关于WPF工具包DataGrid中显示,即使浏览的属性字段设置为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!