问题描述
我有一个WPF Datagrid(在Win7上为4.0).当通过拖动(拖动)滚动到末尾时,它有时会返回放开一点,鼠标光标移开(可能从整行开始).我尝试设置DG_ScrollViewer的CanContentScroll属性(请参阅 WPF DataGrid:CanContentScroll属性会导致奇怪的行为),但是当填充大量数据时,网格会变得异常缓慢.
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.!
推荐答案
如果找到了原因.有一个处理程序导致此行为.
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.
这篇关于WPF Datagrid滚动到结束时会向上滚动一点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!