WPF Datagrid scrolls up a bit when scrolled to end

橙三吉。 提交于 2019-12-11 17:59:57

问题


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:


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.



来源:https://stackoverflow.com/questions/10601687/wpf-datagrid-scrolls-up-a-bit-when-scrolled-to-end

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!