How to autoscroll on WPF datagrid

后端 未结 17 971
甜味超标
甜味超标 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:26

    If you are using MVVM pattern, you can have a combination of this article with this other: http://www.codeproject.com/KB/WPF/AccessControlsInViewModel.aspx.

    The idea is to use attached properties to access the control in your ViewModel class. Once you do that, you would need to check that the datagrid is not null, and it has any items.

    if ((mainDataGrid != null) && (mainDataGrid.Items.Count > 0)){
    //Same snippet
    }
    

提交回复
热议问题