does the wpf datagrid have a virtual mode like the winforms DataGridView?

最后都变了- 提交于 2019-12-07 09:51:35

问题


The winforms DataGridView has a virtual model and uses the OnCellValueNeeded method to gets cell values from a a user defined data store.

How do i do this in wpf? The DataGrid doesn't seems to have a OnCellValueNeeded method.

Thanks


回答1:


Not sure if this already helps you:

DataGrid uses UI virtualization, what means that objects are not created before they are visible on screen and the corresponding properties of your source objects will not be called as long as they are not visible. It means also that ui-elements are recycled after they are no more visible.
This is for free and you don't have to do additional coding to use this feature. If I interprete your question right, the main question is, how to know that a property of a business-object is needed. For UI-virtualization, this is when the property is called the first time - You can do some lazy initialization. But beware to put too heavy initialization code into the properties (DB synchronous lookups etc), otherwise your DataGrid will become very slow and unhandy.



来源:https://stackoverflow.com/questions/6982301/does-the-wpf-datagrid-have-a-virtual-mode-like-the-winforms-datagridview

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