lzy_tek

Is there anyway to know the TreeView contend is clipped.



Thanks



Re: Windows Presentation Foundation (WPF) How to scroll a TreeView in code?

lzy_tek

One solution is to put the TreeView inside a ScrollViewer and manipulate the ScrollViewer. I am a little bit surprised that I cannot get the default ScrollViewer from the TreeView directly.





Re: Windows Presentation Foundation (WPF) How to scroll a TreeView in code?

lee d

you should be able to get the scrollviewer from the template

there is sample in this post

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=990543&SiteID=1






Re: Windows Presentation Foundation (WPF) How to scroll a TreeView in code?

lzy_tek

Brilliant! I guess I have to walk the VisualTree to get it. Code snippets from other post:

private ScrollViewer FindScroll()

{

Border scroll_border = VisualTreeHelper.GetChild(TreeView, 0) as Border;

if (scroll_border is Border)

{

ScrollViewer scroll = scroll_border.Child as ScrollViewer;



I sort of understand why TreeView doesn't have a member for its internal ScrollViewer. It may not be defined in customized style.



Thank you very much, Lee!