How to autoscroll on WPF datagrid

后端 未结 17 1026
甜味超标
甜味超标 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条回答
  •  忘掉有多难
    2020-12-08 10:07

    I know this is a late answer, but just for the people that are searching around, I found THE EASYEST way to scroll to the bottom of a DataGrid. in the DataContextChanged event put this in:

    myDataGrid.ScrollIntoView(CollectionView.NewItemPlaceholder);
    

    Easy huh?

    This is why it works: On every data grid there is a place at the bottom of the DataGrid where you can add a new item to your list that it's bound to. That is a CollectionView.NewItemPlaceholder, and there will only be one of those in your DataGrid. So you can just scroll to that.

提交回复
热议问题