1
votes

I've noticed with my DataGrid in WPF that when I set SelectionMode="Extended", the horizontal scrolling becomes really patchy/weird. Some sort of 'select all' type button appears/disappears rapidly on the top left hand corner of the grid, and the headers & columns jump back and forth while scrolling. The scrollbar itself also jumps back and forth while scrolling. Scrolling does sort of work, but the behaviour while scrolling is really buggy looking.

I've noticed that if I set SelectionMode="Single" then the problem disappears, but I'd like to use SelectionMode="Extended". This is the code for my datagrid:

<DataGrid x:Name="dataGrid" SelectionMode="Extended" SelectionUnit="Cell" 
    HeadersVisibility="Row,Column" RowHeaderWidth="0"
    ItemsSource="{Binding ElementName=dataPager, Path=PageView}" 
    CanUserReorderColumns="False"
    CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeRows="False">

Anyone know how to fix this issue? Thanks in advance!

1
Can't reproduce your problem. Are you doing something(in code/VM) when selection changes in DataGrid? or any thing else you haven't mentioned.akjoshi
Not doing anything with the datagrid in code, just working with the datasource in the viewmodel. If you are unable to reproduce the problem, it must have something to do with the styling of the datagrid/datagridcolumnheader, although I don't see anything too strange in there...JPProgrammer

1 Answers

6
votes

So I figured out a solution to my problem. I figured that it was the 'select all' button that was causing the problems with the way it was appearing/disappearing during scrolling, so I looked into what makes that button appear and how to make it not appear. Turns out the problem was with the row header, so I changed:

HeadersVisibility="Row,Column"

to:

HeadersVisibility="Column"

After removing the row part in the header visibility the 'select all' button stopped appearing, and scrolling occurred as it was supposed to. Still not entirely sure why the 'select all' button was appearing/disappearing the way it was though...