开发者

DataGrid scrolling issue fix leads to performance and memory issue

开发者 https://www.devze.com 2023-04-02 17:50 出处:网络
We had issue with the Scrolling of the WPF datagrid. With some analysis found the ScrollViewer.CanContentScroll = true was the culprit. Removing and making it false, the scrolling issue was fixed. BUT

We had issue with the Scrolling of the WPF datagrid. With some analysis found the ScrollViewer.CanContentScroll = true was the culprit. Removing and making it false, the scrolling issue was fixed. BUT yesterday i was analyzing a bug on increase in memory footprint of the WPF application to more than 1.3Gb due to binding a 50k records by mistake. Still it questioned the capabilities of binding even a 10k records. Users dont want pagination. ( its a requirement, cant do much about it!)

On further reader found setting ScrollViewer.CanContentScroll = false makes UI virtualization false. which is making WPF bind all the records and render it on the screen. Which results in exploded memory foot print and performance issues.

For now we thought if the records to be bound are minimal, then set the ScrollViewer.CanContentScroll= false, else set it true.

In short: we are either stuck with scrolling issue or UI 开发者_StackOverflow社区virtualization. Is there something which can fix both? Have read about Data Virtualization but do we really need to go that far? am i missing anything out of the box from .net4.0 which could help us?


If you check out the accepted answer of this question... In the 'Choosing between them' section of the answer there is a suggested tip to set the visibility of a custom decorator to hidden when the item is not in view.

But other than that... you're right. You either get smooth scrolling or virtualization... not both.

Additionally, if you group items in your datagrid, check out this answer I posted a while back for a convenient performance improvement.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号