当行高于视口时,如何使DataGrid平滑滚动? [英] How can I get a DataGrid to scroll smoothly when the Row is taller than the Viewport?

查看:140
本文介绍了当行高于视口时,如何使DataGrid平滑滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个充满笔记的DataGrid,并且可能会使DataGrid的高度更高。当这种情况发生时,如果您尝试向下滚动阅读笔记的下半部分,DataGrid将立即跳到下一行。



这不仅可以阻止用户查看完整的笔记,但也会导致滚动感觉不舒服,因为它似乎跳动。



有没有办法告诉WPF滚动顺利通过一个长的音符,而不会禁用默认的DataGrid虚拟化?

解决方案

我相信你正在寻找 VirtualizingPanel.ScrollUnit 附加属性,您可以在DataGrid上设置。



如果将其值设置为 Pixel 而不是默认的项目,它应该做你想要的。


I have a DataGrid full of notes, and it's possible that a note will be taller then the DataGrid's height. When this happens, if you try and scroll down to read the bottom half of the note, the DataGrid immediately skips to the next row.

This not only prevents users from viewing the full note, but also causes the scrolling to feel choppy because it appears to jump around.

Is there a way to tell WPF to scroll smoothly past a long note without disabling the default DataGrid virtualization?

解决方案

I believe you are looking for the VirtualizingPanel.ScrollUnit attached property which you can set on the DataGrid.

If you set its value to Pixel instead of the default Item, it should do what you want.

这篇关于当行高于视口时,如何使DataGrid平滑滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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