捕获指针到不同的控件? [英] Capturing Pointer to a different control?

查看:52
本文介绍了捕获指针到不同的控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用操作事件实现拖放,但在MVVM友好方式中这样做并不简单,因为似乎无法将操作从一个控件转移到另一个控件(即源代码)控制装饰控制)。 
在WPF中你可以使用

I am trying to implement drag and drop using the manipulation events but it is not straightforward to do so in an MVVM friendly-way as it does not seem possible to transfer the manipulation from one control to another (i.e. source control to adorner control).  In WPF you could transfer the touches using

foreach (var touch in control.TouchesCaptured)
    adorner.CaptureTouch(touch);

但Metro应用程序中的相应代码不会更新PointerCaptures(在装饰器上):

But the corresponding code in a Metro app does not update PointerCaptures (on the adorner):

foreach (var pointer in control.PointerCaptures)
    adorner.CapturePointer(pointer);


这只是CapturePointer的一个错误,还是Metro不支持这种操作转移?

Is this just a bug with CapturePointer or is this kind of manipulation transfer not supported in Metro?

推荐答案

你好孟德尔,

你无法捕获已被捕获的指针。如果你从CapturePointer调用中查看返回值,你会发现它是错误的。如果您首先从原始控件释放捕获并且
然后将其捕获到装配器,您应该能够获得所需的效果:

You cannot capture a pointer that is already being captured. If you look at the return value from your CapturePointer call you'll see it is false. You should be able to get the effect you want if you first release the capture from the original control and then capture it to the adorner:

foreach (var pointer in control.PointerCaptures)
{
    control.ReleasePointerCapture(pointer);
    adorner.CapturePointer(pointer);
}




- 行记录


--Rob


这篇关于捕获指针到不同的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆