How to autoscroll on WPF datagrid

后端 未结 17 1012
甜味超标
甜味超标 2020-12-08 09:27

I think I am stupid. I searched now for 15 minutes, and found several different solutions for scrolling on datagrids, but none seems to work for me.

I am using WPF w

17条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 10:30

    if large data datagrid.ScrollIntoView(itemInRow, column); not works fine then we need to use below one only:

    if (mainDataGrid.Items.Count > 0) 
            { 
                var border = VisualTreeHelper.GetChild(mainDataGrid, 0) as Decorator; 
                if (border != null) 
                { 
                    var scroll = border.Child as ScrollViewer; 
                    if (scroll != null) scroll.ScrollToEnd(); 
                } 
            } 
    

提交回复
热议问题