wpf datagrid是否具有类似winforms DataGridView的虚拟模式?

时间:2021-03-20 17:28:02

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

winforms DataGridView具有虚拟模型,并使用OnCellValueNeeded方法从用户定义的数据存储中获取单元格值。

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

我如何在wpf中执行此操作? DataGrid似乎没有OnCellValueNeeded方法。

Thanks

1 个解决方案

#1


4  

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.

DataGrid使用UI虚拟化,这意味着在屏幕上可见对象之前不会创建对象,只要它们不可见,就不会调用源对象的相应属性。这也意味着ui元素在不再可见之后被回收。这是免费的,您无需执行其他编码即可使用此功能。如果我正确解释您的问题,主要问题是,如何知道需要业务对象的属性。对于UI虚拟化,这是第一次调用属性时 - 您可以进行一些延迟初始化。但要注意将过多的初始化代码放入属性(数据库同步查找等),否则你的DataGrid将变得非常缓慢和不方便。

#1


4  

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.

DataGrid使用UI虚拟化,这意味着在屏幕上可见对象之前不会创建对象,只要它们不可见,就不会调用源对象的相应属性。这也意味着ui元素在不再可见之后被回收。这是免费的,您无需执行其他编码即可使用此功能。如果我正确解释您的问题,主要问题是,如何知道需要业务对象的属性。对于UI虚拟化,这是第一次调用属性时 - 您可以进行一些延迟初始化。但要注意将过多的初始化代码放入属性(数据库同步查找等),否则你的DataGrid将变得非常缓慢和不方便。