WPF DataGrid: how do I stop auto scrolling when a cell is clicked?

前端 未结 9 1147
旧巷少年郎
旧巷少年郎 2020-12-08 07:31

Problem:
If my DataGrid is not entirely visible (horizontal & vertical scrollbars are showing) and I click on one of my cells that is p

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 07:57

    Define an EventSetter in the DataGrid.RowStyle to call a handler that prevents the row from being brought into view:

    XAML

    
        
            
        
    
    

    Handler

    private void DataGrid_Documents_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
    {
        e.Handled = true;      
    }
    

提交回复
热议问题