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

查看:21
本文介绍了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.

一个工厂用于为每一行创建CheckBoxes.

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

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

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天全站免登陆