JPProgrammer
JPProgrammer

Reputation: 506

wpf datagrid horizontal scrolling bug?

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!

Upvotes: 1

Views: 2777

Answers (1)

JPProgrammer
JPProgrammer

Reputation: 506

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...

Upvotes: 7

Related Questions