实现自行调节scoll滚动的位置(可相应获取任何控件中的内部滚动条)
TreeView:
TreeViewAutomationPeer lvap = new TreeViewAutomationPeer(treeView);
var svap = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
var scroll = svap.Owner as ScrollViewer;
//此处添加你想要对TreeView自身滚动条的操作
scroll.ScrollToVerticalOffset(scroll.VerticalOffset+1); //向下调节垂直滚动
ListView:
ListViewAutomationPeer lvap = new ListViewAutomationPeer(listView);
var svap = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
var scroll = svap.Owner as ScrollViewer;
//此处添加你想要对TreeView自身滚动条的操作
scroll.ScrollToVerticalOffset(scroll.VerticalOffset+1); //向下调节垂直滚动条的位置;
资料
拖放概述 - WPF .NET Framework | Microsoft Learn
注意这个属性需要开启