开发者

WPF: Determine/Set position of vertical Scrollbar

I've got a FlowDocumentScrollViewer with a vertical scrollbar. Now I want to know its posit开发者_开发技巧ion and also be able to change it.


Looking up the visual tree seems to be the best way to get the ScrollViewer-Object.

       DependencyObject obj = this.DocumentScrollViewer;

        do
        {
             if (VisualTreeHelper.GetChildrenCount(obj) > 0)
             {
                obj = VisualTreeHelper.GetChild(obj as Visual, 0);
             }
        }
        while (!(obj is ScrollViewer));

        this.scroller = obj as ScrollViewer;

That comes with methods such as ScrollToVerticalOffset(..) and ScrollableHeight which enable me to do everything I wanted.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜