为什么 ScrollViewer 中鼠标滚轮滚动消失了?
我在 TreeView 周围添加 ScrollViewer 有两个原因:
我想要更多地控制 TreeView 滚动条的外观
我想要更多的控制在我的 TreeView 滚动条位置上,因为我想同步一些树视图。
似乎一旦我在 TreeView 周围添加 ScrollView ,我就失去了使用鼠标滚动器滚动它的能力。
我想我的问题分为两部分。通过添加自己的 ScrollView 我可以获得什么好处吗?这是设计使然吗?
I am adding a ScrollViewer around my TreeView for 2 reasons:
i want more control over the way my TreeView scroll bar looks
i want more control over my TreeView scroll bars position, because i want to synchronize a few tree views.
it seems that as soon as i add a ScrollView around TreeView, i lose the ability to scroll it using mouse scroller.
I guess my question is 2 part. Do i gain anything by adding my own ScrollView, and is this behavior by design?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您的任何一个要求都不排除使用
TreeView
模板中的ScrollViewer
。您可能需要重新模板化TreeView
才能实现您的目标。这也揭示了为什么滚动不能按预期工作。您实际上已经在
ScrollViewer
周围获得了一个ScrollViewer
。为此,您需要做的就是从 TreeView 模板中删除 ScrollViewer,或者禁用它:也就是说,我确实认为您的情况下更好的选择可能是重新模板/重新设计
TreeView 本身。
I don't think either of your requirements precludes using the
ScrollViewer
that is within theTreeView
template. You might need to re-template theTreeView
to achieve your goals.This also sheds light on why your scrolling doesn't work as expected. You've effectively got a
ScrollViewer
around aScrollViewer
. What you would need to do for that to work is either remove the ScrollViewer from the TreeView template, or disable it:That said, I do think the better option in your case may be to re-template/re-style the
TreeView
itself.您可以重新模板树视图以删除内部滚动查看器
you can retemplate your treeview to remove the inner scrollviewer