如何在wpf touch应用程序中阻止对象移过窗口边界? [英] How to stop objects from moving past the window boundary in wpf touch application?

查看:66
本文介绍了如何在wpf touch应用程序中阻止对象移过窗口边界?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个基于触摸的wpf应用程序,其中在交互时弹出按钮和列表框.通过操作,可以在屏幕上移动对象.我使用了ManipulationStarting,ManipulationDelta和ManipulationInertia事件来执行它们. 如何阻止对象移过屏幕?按钮和列表框位于(画布和堆栈面板)>网格>窗口中.

I have created a touch based wpf application wherein buttons and listbox popup on interaction. On manipulation the objects can be moved across the screen. I have used ManipulationStarting, ManipulationDelta and ManipulationInertia events to execute them. How do I stop the objects from moving past the screen? The button and listbox are placed inside a (Canvas and stackpanel)>Grid>Window. 

推荐答案


SrMusashi,


Hi SrMusas

>>如何阻止对象移过屏幕?

您可以通过将元素的边界与父边界的边界进行检查,尝试使该元素在到达窗口边界时停止.

You can try to make the element stop when it hits a window boundary by checking its bounds against the bounds of its parent.

您可以参考以下详细文章.

You can refer the following detailed articles.

在触摸操作期间在窗口内保留元素:
https://wpf.2000things.com /2013/01/29/744,在触摸操作期间在窗口内保留一个元素/

Keeping an Element within Window During Touch Manipulation:
https://wpf.2000things.com/2013/01/29/744-keeping-an-element-within-window-during-touch-manipulation/

使用触摸操作事件来翻译元素:
https://wpf.2000things.com /2013/01/24/741-使用touch-manipulation-events来翻译元素/

Using Touch Manipulation Events to Translate an Element:
https://wpf.2000things.com/2013/01/24/741-using-touch-manipulation-events-to-translate-an-element/

以下链接供您参考.

我正在使用WM_POINTER在我们的项目中应用触摸.如果轻拂一个对象(快速移动),我想将我的对象停在窗口边界处?

I am using WM_POINTER to apply touch in our project .In the case of flick a object(fast move) ,i want to stop my object at the window boundary??
https://social.msdn.microsoft.com/Forums/vstudio/en-US/ea9e0744-d09f-4f54-a731-2ef4962af530/i-am-using-wmpointer-to-apply-touch-in-our-project-in-the-case-of-flick-a-objectfast-move-i?forum=vcgeneral


注意:此响应包含对第三方万维网站点的引用. Microsoft为方便您而提供此信息. Microsoft不控制这些站点,也没有测试在这些站点上找到的任何软件或信息;所以, Microsoft无法对在此找到的任何软件或信息的质量,安全性或适用性做出任何陈述.使用Internet上发现的任何软件都存在固有的危险,Microsoft提醒您确保自己 从Internet上检索任何软件之前,请完全了解风险.


Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

最好的问候,

Yohann Lu

Yohann Lu


这篇关于如何在wpf touch应用程序中阻止对象移过窗口边界?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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