[英]WPF: Datagrid is updating header after adding or removing item at binding collection
I have binded a ObservableCollection (loaded from an ORM) to a WPF-DataGrid and on programm start I'm changing the header titles, adding self-developed AutoFilters to the column headers and setting some columns to visibility collapsed. 我已经将ObservableCollection(从ORM加载)绑定到WPF-DataGrid,并且在编程开始时,我正在更改标题标题,将自行开发的自动筛选器添加到列标题,并将一些列设置为可见性折叠。 That works everything very well.
那一切都很好。
But if I'm adding an new or removing an excisting Item to/from the ObservableCollection then the DataGrid refreshes completely and I'm loosing the changed column titles, the AutoFilters and the columns I have collapsed on program start are also visible. 但是,如果我向ObservableCollection添加新项或从ObservableCollection中删除现有项,则DataGrid会完全刷新,并且丢失更改的列标题,在程序启动时折叠的AutoFilter和列也可见。
At the moment I don't know how I can solve this problem. 目前,我不知道该如何解决这个问题。 I'm looking forward for your help.
我期待着您的帮助。
Thank you! 谢谢!
Try setting AutoGenerateColumns
of the DataGrid
to False
. 尝试将
DataGrid
AutoGenerateColumns
设置为False
。
For example: 例如:
<DataGrid AutoGenerateColumns="False">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.