开发者

How to have a vertical scrollbar for a WPF TreeView, but not the horizontal scrollbar?

I have a TreeView (the only co开发者_如何学JAVAntrol) inside a Grid, and I only want to see the vertical scrollbar when the height isn't enough.

To not have the horizontal scrollbar, I have to account for its width to the width of the TreeView, right? But when I only specify the width to stretch the TreeView's width to the width of the Window, no scrollbar appears.

Is there a way to solve this?

Alternatively if I can make it so that I don't have to specify the width and height of the TreeView and it resizes its width when the height isn't enough, to fit the vertical scrollbar, that would be the best.


I use these attributes on my TreeView's ScrollViewer:

<TreeView ScrollViewer.VerticalScrollBarVisibility="Auto"
          ScrollViewer.HorizontalScrollBarVisibility="Disabled" />

As long as the width of your TreeView's content stretches to just fit the width of your TreeView, you should be fine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜