I have a DataGrid WPF that I have been using for some time and it works great. Unlike the other posters here, I had no problems with the scroll wheel or mouse wheel (for now). I have CTRL END programmed to go to the end of a DataGrid and then it keeps track of the most recently added items. I can scroll the contents of a DataGrid using the up key.
However, I have a really weird behavior with the down key! If I start at the top of my DataGrid and hold down , it scrolls a bit and then eventually bounces back and forth between two adjacent rows. If I pgdn , it will scroll down and then return to the top of the previous two lines between which it will jump, then scroll down to the point at which I pgdn 'd. If I write a few more, the down key will scroll to the end. If I go to the beginning of the DataGrid and start over, I get the same behavior again and again.
I still need to find a message that addresses this, and I have not seen anything in the DataGrid documentation that helps.
These are just three columns of the DataGrid , where TextBlock s is displayed in each column. Can someone explain why this particular scroll mode is problematic? Here is the XAML:
<DataGrid ItemsSource="{Binding MainLog}" AutoGenerateColumns="False" Name="log_datagrid" SelectedCellsChanged="log_datagrid_SelectedCellsChanged" KeyUp="datagrid_KeyUp" LoadingRow="log_datagrid_LoadingRow"> <DataGrid.Columns> <DataGridTemplateColumn Header="Timestamp"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Timestamp}" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn Header="Level"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Level}" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn Header="Message"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Message}" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> </DataGrid.Columns> </DataGrid>
By the way, this behavior happens even with all my code for event handlers.
Here is the structure definition that my MainLog collection contains:
public struct MainLogData { public string Timestamp { get; set; } public string Level { get; set; } public string Message { get; set; } }
source share