为 WPF 树视图启用滚动 [英] Enable scroll for WPF Treeview

查看:53
本文介绍了为 WPF 树视图启用滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我了解如何启用树视图滚动?必须有一个简单的方法,但我不能让它在我的代码中工作.经过多次失败的尝试,我目前有这样的事情:

Can anybody help me out with how to enable a treeview to scroll? There must be a simple way but I can't make it work in my code. After multiple failed tries, I currently have something like this:

        <ScrollViewer CanContentScroll="True">
           <TreeView ...>
           </TreeView>
        </ScrollViewer>

我确实看到了一个禁用"的滚动条,但是当树状视图的注释大于屏幕高度时,不会激活滚动条.

I do see an 'disabled' scrollbar, but when the notes of the treeview are larger than the screen height, no scrolling is activated.

推荐答案

TreeView 控件本身在其模板中包含一个 ScrollViewer.您应该能够在适当的主机中使用 TreeView(而不是 StackPanel!).

The TreeView control itself includes a ScrollViewer in its template. You should be able to just use a TreeView inside an appropriate host (not a StackPanel!).

这篇关于为 WPF 树视图启用滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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