滚动时 wpf datagrid 单元格样式的问题 [英] issue with wpf datagrid cell style when scrolling

查看:24
本文介绍了滚动时 wpf datagrid 单元格样式的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的 wpf 数据网格(红色边框画笔)创建了一个新的 DataGridCell 样式.当我垂直向下滚动时,选定的单元格消失了,这没关系.当我向上滚动时,我会看到选定的单元格,但其中很少有缺少样式并且出现在错误的单元格中.

I created a new DataGridCell style for my wpf datagrid (Red Border brush). When I scroll down vertically the selected cells disappear which is ok. When I scroll up I see the selected cells but few of them missing their style and it appear in wrong cells.

看起来数据网格记住了选定的单元格,但忘记"了它们的样式.

It look like the data grid remember the selected cells but "forget" their style.

有什么想法吗?

哈姆

推荐答案

没有更多细节,我只能猜测您遇到的工件是重复使用虚拟化单元的结果.您可以通过禁用列和行虚拟化来测试:

Without any more details I can only guess that artifacts you're experiencing are a result of reusing of virtualized cells. You can test this by disabling column and row virtualization:

<DataGrid EnableRowVirtualization="False" EnableColumnVirtualization="False" ...

此外,如果这没有帮助,您是否有机会覆盖数据项的 Equals 方法?ItemsControls 在显示多个相同的项目时偶尔会出现故障.

Also, if this doesn't help did you by any chance override the Equals method of your data items? ItemsControls occasionally glitch when they display several equal items.

这篇关于滚动时 wpf datagrid 单元格样式的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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