How to give scroll bar to an WPF treeview [closed]
I have used the
<ScrollViewer CanContentScroll="True">
<TreeView ...>
</TreeView>
</ScrollViewer>
but not properly working I want a new one
TreeView
manages its own scroll viewer. You'll want to set either ScrollViewer.HorizontalScrollBarVisibility
or ScrollViewer.VerticalScrollBarVisiblity
to Visible
on the tree view itself to force the respective scrollbars to display.
<TreeView
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.HorizontalScrollBarVisibility="Visible" />
Also, make sure your TreeView doesn't live inside a control that will extend vertically forever - a common mistake is this:
<StackPanel>
<... />
<TreeView>
In this example, the TreeView will grow longer and longer without scrolling, because the StackPanel has infinite height.
精彩评论