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