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

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

XAML

<DataGrid>
    <DataGrid.RowStyle>
        <Style TargetType="{x:Type DataGridRow}">  
            <EventSetter Event="Control.RequestBringIntoView" Handler="DataGrid_Documents_RequestBringIntoView"  />
        </Style>
    </DataGrid.RowStyle>
</DataGrid>

Handler

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)