WPF鼠标滚轮方向检测和故事板
我正在开发一个显示 XAML 对象的 WPF 应用程序,并且我希望使用鼠标滚轮放大和缩小 XAML 对象。我可以为鼠标滚轮创建 XAML 对象的良好平滑过渡,但我无法理解如何区分鼠标滚轮方向。我发现我应该使用触发器的属性,但我找不到如何对鼠标滚轮执行此操作。
这是我到目前为止的代码,它会触发任何鼠标滚轮操作(向上或向下):
<UserControl.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseWheel" >
<BeginStoryboard Storyboard="{StaticResource OnMouseWheel1}"/>
</EventTrigger>
</UserControl.Triggers>
感谢所有的帮助者:)
I'm working on a WPF application that displays a XAML object and I wish to zoom in and out from the XAML object by using the mouse wheel. I could create a nice smooth transition of the XAML object for the mouse wheel but I cannot understand how to differentiate between the mouse wheel direction. I found out that I should use the Trigger's properties, but I can't find how to do this for the mouse wheel.
This is the code I have so far, and it fires for any mouse wheel action (either up or down):
<UserControl.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseWheel" >
<BeginStoryboard Storyboard="{StaticResource OnMouseWheel1}"/>
</EventTrigger>
</UserControl.Triggers>
Thanks to all you helpers out there :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 WPF XAML Canvas,这可能有助于实现一个好的故事板。检查http://msdn.microsoft.com/en-us/library/cc294753。 aspx
这是一个简短的示例,您可能需要使用 DoobleAnimation。
对我来说,最好开发背后的代码。
You can use WPF XAML Canvas this may help to implement a good storyboard. Check http://msdn.microsoft.com/en-us/library/cc294753.aspx
This is a short example, you may need to use DoobleAnimation.
For me it is better to develop that a code behind.