WPF 沿路径轻拂(表面)
我正在为 Microsoft Surface 开发一个应用程序,我正在尝试充分利用现有的库,我想要的功能是能够轻弹 UI 元素。
ScatterView 控件使这变得简单,但我想限制 UI 元素只能沿着设定的路径轻弹。这就是我遇到麻烦的地方。
所以我的问题是:
1)你能限制 ScatterViewItem 只能沿着路径轻弹吗?
2) 如果没有,您将如何实现轻弹手势以沿着设定的路径轻弹 UI 元素?
谢谢!
标记
Im developing an app for Microsoft Surface and Im trying to make the most of the libraries that are out there, the functionality Im after if to be able to flick a UI element.
The ScatterView control makes this easy, but I would like to restrict the UI element to only be able to be flicked along a set path. This is where Im having trouble.
So my questions are:
1) Can you restrict a ScatterViewItem to only be flicked along a path?
2) If not, how would you implement a flick gesture to flick a UI element along a set path?
Thanks!
Mark
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1) 据我所知,这可能不是解决这个问题的最佳方法。
2)假设您在设计时拥有想要轻弹的对象和路径,我之前通过创建表示整个路径上的移动的时间轴动画来实现沿路径拖动和轻弹。在运行时,我捕获该对象上的接触,将它们提供给 Affine2DManipulationProcessor,并根据操作事件寻找动画。
所以就我而言,我正在创建一个抽屉。当用户触摸抽屉时,我启动动画并立即暂停。如果用户将其拖动打开,我会根据操纵处理器告诉我它们移动的距离,将动画向前移动适当的量。
要获得轻弹行为,您只需将操作交给 Affine2DInertiaProcessor 并继续处理增量事件。
这一切都效果出奇的好。
1) Not that I know of, and this probably isn't the best way to approach it.
2) Assuming you have the object you want flicked and the path at design-time, I've previously implemented dragging and flicking along a path by creating a timeline animation that represents the movement across the entire path. At runtime, I capture contacts on that object, feed them to a Affine2DManipulationProcessor, and seek the animation based on the manipulation events.
So in my case I was creating a drawer. When the user touched the drawer, I start the animation and pause it immediately. If the user drags it open, I seek the animation the appropriate amount forward based on how far the manipulation processor tells me they've moved.
To get the flick behavior, you just hand off the manipulation to the Affine2DInertiaProcessor and continue handling the delta events.
This all works surprisingly well.