如何构建一个控件,可以在一个方向上滚动内容,并在交叉滑动时开始拖动项目。 [英] How to build a control that can scroll content in one direction and start dragging items when cross-sliding.
问题描述
昨天我了解到我无法自定义GridView的拖动启动阈值,并且我需要实现自己的控件来控制交叉幻灯片重新排列阈值。 http://social.msdn.microsoft。 com /论坛/ zh-CN / winappswithcsharp / thread / 2eda3952-da71-4b15-aaee-9f865f680965
I learned yesterday that I can't customize the drag start threshold of a GridView and that I need to implement my own control to have control over the cross-slide rearrange threshold. http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/2eda3952-da71-4b15-aaee-9f865f680965
所以我'一直试图这样做。 我从一些简单的事情开始:
So I've been trying to do that. I started with something simple:
<ScrollViewer
VerticalScrollMode="Disabled"
VerticalScrollBarVisibility="Hidden"
HorizontalScrollMode="Enabled"
HorizontalScrollBarVisibility="Auto"
ZoomMode="Disabled" Height="150"
VerticalAlignment="Bottom">
<local:DragSource Height="150" VerticalAlignment="Bottom"/>
</ScrollViewer>
DragSource是一个用户用堆栈面板和一堆矩形控制。 DragSource处理PointerPressed,PointerMoved和PointerReleased并将它们传递给GestureRecognizer。 在PointerPressed上,DragSource捕获鼠标。 但是,
它会立即丢失鼠标捕获(大概是ScrollViewer)。 如果我将DragSource从ScrollViewer中取出,DragSource会保留鼠标捕获,并且手势识别器会按预期触发CrossSlide事件。
DragSource is a user control with a stack panel and a bunch of rectangles. DragSource handles PointerPressed, PointerMoved and PointerReleased and passes them to a GestureRecognizer. On PointerPressed, the DragSource captures the mouse. However, it immediately loses mouse capture (presumably to the ScrollViewer). If I take DragSource out of the ScrollViewer, DragSource retains the mouse capture, and the gesture recognizer fires the CrossSlide events as expected.
如何让ScrollViewer与CrossSliding子元素很好地配合? 这似乎应该很简单。 如果我向一个方向滑动,我想滚动,如果我向另一个方向滑动,我想开始拖动操作。
How do I get the ScrollViewer to play nicely with CrossSliding child elements? This seems like it should be simple. If I swipe in one direction, I want to scroll, if I swipe the other direction, I want to start a drag operation.
推荐答案
罗伯特 - 给我发电子邮件列表。 MSMALL在微软。
Robert - email me off-list. MSMALL at Microsoft.
这篇关于如何构建一个控件,可以在一个方向上滚动内容,并在交叉滑动时开始拖动项目。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!