2
我正在绑定实现我的应用程序中的拖动滚动功能,并在我的方式有问题。有谁能够帮助我? 我有一个ScrollViewer,里面有一个ItemsControl和ItemsTemplate内我有一个UserControl。我想在ItemsControl中拖动该用户控件。当我拖动到ItemsControl的边界时,我想让ScrollViewer向下滚动。WPF拖动滚动不能正常工作
protected override void OnPreviewMouseMove(System.Windows.Input.MouseEventArgs e)
{
if (this.IsMouseCaptured)
{
// Get the new mouse position.
Point mouseDragCurrentPoint = e.GetPosition(this);
if (Math.Abs(mouseDragCurrentPoint.Y - this.ActualHeight) <= 50)
{
this._scrollStartOffset.Y += 5;
_containingScrollViewer.ScrollToVerticalOffset(this._scrollStartOffset.Y);
}
if (mouseDragCurrentPoint.Y <= 50)
{
this._scrollStartOffset.Y -= 5;
_containingScrollViewer.ScrollToVerticalOffset(this._scrollStartOffset.Y);
}
}
base.OnPreviewMouseMove(e);
}
当我开始拖动通过调用DragDrop.DoDragDrop()
滚动不会发生。但是,当我禁用拖动时,ScrollViewer会向下滚动鼠标位置上的位置。 也许有些东西我没有考虑拖动和捕捉鼠标? 感谢您的关注。 Garegin