0
votes

I have a WPF Datagrid (4.0 on Win7). When it is scrolled to very end by dragging (after dragging) the thumb it sometimes returns a bit when released and mouse cursor moves away (probably to start with a complete line). I tried to set CanContentScroll property of DG_ScrollViewer (see WPF DataGrid : CanContentScroll property causing odd behavior) but the grid become unusably slow when populated with lot of data.

The problem doesn't occur when scrolling is done by mouse wheel (after scrolling with wheel) or clicking a scrollbar arrow.

The problem occures also with horizontal scroling.!

1
Interesting. On my system, wpf datagrids always skip a full row when scrolling, even dragging the thumb. The top of the datagrid always aligns with the top of a row. I cannot get it to scroll, say, half-a-row in order to cause the behavior you're seeing.Eren Ersönmez
@ErenErsönmez: Maybe it is connected with EnableColumnVirtualization="True" EnableRowVirtualization="True" but I did not tried to remove it.IvanH
No. Those properties don't seem to make a difference in what I'm seeing.Eren Ersönmez
@ErenErsönmez: The effect is much more significant when bottom lines are higher (multi line text).IvanH
Are you sure its not your mouse that's actually bouncing up, causing the thumb to scroll? I don't see why the mouse wheel should be any different than the scroll bar.Kyeotic

1 Answers

0
votes

If found the reason. There was a handler causing the behavior.

Private Sub mMainGrid_PreviewMouseUp(sender As Object, e As System.Windows.Input.MouseButtonEventArgs) Handles MyGrid.PreviewMouseUp
        If TypeOf e.OriginalSource Is Thumb Then
            MyGrid.Items.Refresh()
        End If
    End Sub

The aim of this handler is to force refresh a header when a column is resized.