0

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

Community
  • 1
  • 1
IvanH
  • 5,039
  • 14
  • 60
  • 81
  • 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 May 15 '12 at 14:09
  • @ErenErsönmez: Maybe it is connected with EnableColumnVirtualization="True" EnableRowVirtualization="True" but I did not tried to remove it. – IvanH May 15 '12 at 14:21
  • 1
    No. Those properties don't seem to make a difference in what I'm seeing. – Eren Ersönmez May 15 '12 at 14:26
  • @ErenErsönmez: The effect is much more significant when bottom lines are higher (multi line text). – IvanH May 15 '12 at 14:32
  • 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 May 15 '12 at 16:05
  • @Tyrsius: You mean that I somehow release the thumb. It could be, but I saw the problem disappear with CanContentScroll = false and the problem was observed (with the same program) by 5 people on 5 computers with different data. – IvanH May 15 '12 at 17:48
  • Well then you sound like you found it! You should make an answer and mark it. – Kyeotic May 15 '12 at 19:52
  • @ErenErsönmez: Thanks. Your aswer said me it's not a WPF bug. – IvanH May 16 '12 at 14:13

1 Answers1

0

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.

IvanH
  • 5,039
  • 14
  • 60
  • 81