如何让WPF UI幻灯片动画更具物理性? [英] How let WPF UI slide animation more physical?

查看:45
本文介绍了如何让WPF UI幻灯片动画更具物理性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果要滑动屏幕,则需要一些事件.

If we want to slide the screen, we need some events.

Mouse Move Event Mouse Down Event Mouse UP event 但是问题是我们只能在手指触摸屏幕时才能做一些动画,我的意思是:当触摸屏幕时,它会移动,当我们释放它时,它会停止(或放弃它的位置让它停在那里.但是我想像iPhone主屏幕那样做一些动画.如果我们的手指滑动得更快,动画就会更快(或者动画滑动到更远的地方).

Like Mouse Move Event, Mouse Down Event, Mouse UP event But the problem is we only can do some animation only when the finger touch the screen, I mean: when It touch the screen move, it will move, when we release it, it will stop(or give it a position let it stop to there). But I want some animation like IPhone main screen do. If our finger slide more fast, the animation more fast (or the animation slide to more far place).

就像现在我们使用Photoshop一样,当图片缩小到很大时,当我们更快地移动手时,它将移动到很远.

Just like now we use the Photoshop, when the picture zoom out to very large, when we move the hand more fast, it will move to very far.

另一个例子是它会非常缓慢地减速,而不是立即减速.它还会知道我的手指滑动得快或慢....然后它就会滑动得慢或快...

Another example is it will slow down very slowly, not immediately. Also it will know my finger sliding fast , or slow....then it will slide slow or fast...

推荐答案

我使用的代码的修改版本

I use a modified version of the the code found here in my own programs. Usage is simple as it is an attached behavior and can be applied to a style so that all of your scroll viewers automatically behave in this way. It works by using the same (tunneled) events you mention (OnPreviewMouseDown, OnPreviewMouseUp, and OnPreviewMouseMove). During the handling of OnPreviewMouseMove, inertia is calculated and the scrollbar is moved in a simulated physical manner. There is also a friction property which can be set to change the length of time a scrollbar "glides".

这篇关于如何让WPF UI幻灯片动画更具物理性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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