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

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

问题描述

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

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.

有没有办法让 WPF 在不禁用默认的 DataGrid 虚拟化的情况下平滑滚动过一个长音符?

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

推荐答案

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

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

如果您将其值设置为 Pixel 而不是默认的 Item,它应该可以执行您想要的操作.

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

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

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