I have a WPF datagrid where I have tabbing disabled on cells and the virtualizing panel scroll unit set to pixel. When I press PgDn the selected item does not change and so the page down scrolling does not work as standard.
Changing either the cell tab stop to true of the virtualizing panel scroll unit to item puts the page down scrolling back to normal.
Why is this and is it possible to keep both settings while fixing the page down scrolling?
<Window.Resources>
<Style TargetType="DataGridCell">
<Setter Property="IsTabStop" Value="False" />
</Style>
</Window.Resources>
<Grid>
<DataGrid ItemsSource="{Binding Items}"
VirtualizingPanel.ScrollUnit="Pixel">
</DataGrid>
</Grid>
If you take a look at the source code for the DataGrid
, you will see that it handles the KeyDown
event for the PageDown
key in a certain way only when the ScrollUnit
it set to Item
: https://referencesource.microsoft.com/#PresentationFramework/src/Framework/System/Windows/Controls/DataGrid.cs,1e8d30484d9b09db,references
So if you want to this to work, you will have to subclass the DataGrid
class and override the OnKeyDown
method to provide your own custom PageDown
functionality. You may "steal" and modify the private OnPageUpOrDownKeyDown
method according to your requirements.