WPF中获取TreeView以及ListView获取其本身滚动条的方法,可实现自行调节scoll滚动的位置

 

 【转载】   WPF中获取TreeView以及ListView获取其本身滚动条的方法,可实现自行调节scoll滚动的位置                          

转载自:http://blog.csdn.net/yuanshouyan1823/article/details/11179519      
      标签:              wpftreeviewlistview

对于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);    //向下调节垂直滚动条的位置;

posted on 2017-08-17 15:07  蝸小牛  阅读(250)  评论(0编辑  收藏  举报

导航