DataGrid行虚拟化显示问题 [英] DataGrid row virtualization display issue

查看:951
本文介绍了DataGrid行虚拟化显示问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前有一个 DataGrid 绑定到一个 DataTable 。它还有一个模板列,其中包含一个 CheckBox ,它们以编程方式添加。此列的目的是跟踪 DataGrid 中的多个选择。

We currently have a DataGrid that is bound to a DataTable. It also has a template column with a CheckBox in it that we add in programatically. This purpose of this column is track multiple selections in the DataGrid.

工厂用于创建 CheckBox es为每一行。

A factory is used to create the CheckBoxes for each row.

有很多记录,所以行虚拟化设置为true,以便性能是可以接受的但是,我们看到一个奇怪的问题,如果我们在前10行检查一些 CheckBox es,然后向下滚动约50行(网格有大约10行可见任何一次),有一堆其他 CheckBox es似乎随机检查。

There are quite a few records, so row virtualization is set to true so that the performance is acceptable. However, we're seeing a strange issue where if we check some CheckBoxes on the first 10 rows and then scroll down about 50 rows (the grid has about 10 rows visible at any one time), there are a bunch of other CheckBoxes that appear to be checked at random.

如果我们禁用行虚拟化这个问题不存在(但性能是可怕的)。有没有办法解决?任何人都知道我们可能做错了什么?

If we disable row virtualization this problem does not exist (but the performance is terrible). Is there any way around this? Anyone know what we may be doing wrong?

推荐答案

如果你正在寻找速度ListView Gridview快得多(而且有更少的特征)。

If you are looking for speed ListView Gridview is much much faster (and has less features).

尝试禁用容器回收。

             <tk:DataGrid x:Name="dataGrid" 
             ItemsSource="{Binding Path=Bookings}" 
             AutoGenerateColumns="False" 
             EnableRowVirtualization="True" 
             EnableColumnVirtualization="True"
             VirtualizingStackPanel.VirtualizationMode="Standard"
             VirtualizingStackPanel.IsVirtualizing="True">

这篇关于DataGrid行虚拟化显示问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆