Search code examples
wpfscrollrowwpfdatagridalternating

WPF Datagrid with AlternatingRowBackground scrolls differently when scrolled up and down


I have a WPF(4.0 on Win7) datagrid with AlternatingRowBackground when I scroll up row colors remain on place and data are moving when I scroll down colors are moving with data. Is it usual? Is it possible to get rid of this strange behavior?

Grid XAML:

<DataGrid AutoGenerateColumns="True"
                      CanUserAddRows="False"
                      Grid.Row="0" Grid.Column="0"  Name="grdData" 
                      ItemsSource="{Binding Path=.}" SelectionMode="Single"
                      HeadersVisibility="All" 
                      AlternatingRowBackground="LightGray" 
                      />

Note: I have other question about scrolling ( WPF Datagrid scrolls up a bit when scrolled to end ) but I am not sure whether problems are connected.


Solution

  • Add EnableRowVirtualization="False" to your datagrid.