WPF工具包DataGrid的滚动性能问题 - 为什么? [英] WPF Toolkit DataGrid scrolling performance problems - why?

查看:179
本文介绍了WPF工具包DataGrid的滚动性能问题 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与(WPF工具包)的DataGrid性能问题。它包含1.000行(只有八列),并滚动是可怕的缓慢和laggy。还含有DataGrid中窗口的初始加载需要5-10秒。

I have a performance problem with the (WPF Toolkit) DataGrid. It contains about 1.000 rows (only eight columns) and scrolling is horribly slow and laggy. Also the initial load of the Window containing the DataGrid takes 5-10 seconds.

我做了(使用谷歌和计算器)一些研究,但无法找到除了任何意见开启UI虚拟化。但即使显式地使该滚动仍然非常缓慢。

I did some research (using google and StackOverflow) but couldn't find anything besides the advice to turn on UI virtualization. But even after explictly enabling that scrolling continues to be awfully slow.

我的DataGrid绑定为ICollectionView / CollectionViewSource。它是在XAML中定义如下(列被明确定义,不能自动生成):

My DataGrid is bound to an ICollectionView / CollectionViewSource. It's is defined in XAML like this (the columns are explicitly defined, not auto generated):

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



在DataContext为整个窗口设置为包含ICollectionView的类的实例DataGrid绑定到

The DataContext for the entire Window is set to an instance of the class containing the ICollectionView the DataGrid is bound to.

每一个博客或论坛后,我发现在夸DataGrid的表现让我很明显做一些严重错误。因为我很新的WPF一般,尤其是到DataGrid我不如何提高这条线索。 是否有人对我有一些建议吗?什么是使用DataGrid的经验?我在做什么错

Every blog or forum post I found was praising the DataGrid's performance so I'm quite obviously doing something seriously wrong. Since I'm quite new to WPF in general and especially to the DataGrid I've no clue of how to improve this. Does anybody have some advice for me? What's your experience with the DataGrid? What am I doing wrong?

编辑:只是跟着的这个问题的建议设置所有列的宽度为自动。这确实的不可以改变不良的滚动性能。另外我没有使用DataGridTemplateColumns(只是一些DataGridTextColumns和两个DataGridComboBoxColumns)

Just followed this question's advice to set the Width of all columns to "Auto". That did not change the bad scrolling performance. Also I'm not using DataGridTemplateColumns (just some DataGridTextColumns and two DataGridComboBoxColumns).

EDIT2:我用史努比来看看我的应用程序。我看到的建议,虚拟化确实是工作(只有19行,而不是一个千元)。但每行包含52元,所以这些加起来超过一千元素。也许这是一个/问题?

I used Snoop to look at my app. What I see suggests that virtualization is indeed working (only 19 rows, not a thousand). But every row contains 52 elements, so those add up to more than thousand elements. Might that be a / the problem?

非常感谢!

推荐答案

终于使得构建我的应用程序对WPF的一个上最新版本的滚动问题似乎完全消失的时间之后。因此,如果有人还在使用DataGrid只是升级为版本的版本工具包中包含的框架和你应该罚款。

After finally making the time to build my application against an up-to-date version of WPF the scrolling problem seems completely gone. So if anyone still uses the toolkit version of the DataGrid just "update" to the version included in the framework and you should be fine.

这篇关于WPF工具包DataGrid的滚动性能问题 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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