Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF:确定/设置垂直滚动条的位置_C#_.net_Wpf_Visual Studio - Fatal编程技术网

C# WPF:确定/设置垂直滚动条的位置

C# WPF:确定/设置垂直滚动条的位置,c#,.net,wpf,visual-studio,C#,.net,Wpf,Visual Studio,我有一个带有垂直滚动条的FlowDocumentScrollViewer。 现在我想知道它的位置,并且能够更改它。查找可视化树似乎是获取ScrollViewer对象的最佳方法 DependencyObject obj = this.DocumentScrollViewer; do { if (VisualTreeHelper.GetChildrenCount(obj) > 0) {

我有一个带有垂直滚动条的FlowDocumentScrollViewer。
现在我想知道它的位置,并且能够更改它。

查找可视化树似乎是获取ScrollViewer对象的最佳方法

       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;
它附带了ScrollToVerticalOffset(..)和ScrollableHeight等方法,使我能够做任何我想做的事情