在XAML中暂停动画 [英] Pausing an animation in XAML

查看:66
本文介绍了在XAML中暂停动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个动画,该动画会淡入和淡出View上的控件.我通过在应用程序的视图模型"中设置布尔值来启动动画.

Hi,

I have an animation that fades in and fades out a control on my View. I initiate the animations by setting boolean values in the View Model of the application.

<border.style>>
									<Style>
										<Style.Triggers>
											<DataTrigger Binding="{Binding FadeIn}" Value="True">
												<DataTrigger.EnterActions>
													<BeginStoryboard>
														<Storyboard >
															<DoubleAnimation Duration="0:0:0.5"
															                 Storyboard.TargetProperty="Opacity"
															                 To="1" />
														</Storyboard>
													</BeginStoryboard>
												</DataTrigger.EnterActions>
												<DataTrigger.ExitActions>
													<BeginStoryboard>
														<Storyboard>
															<DoubleAnimation Duration="0:0:1"

															                 Storyboard.TargetProperty="Opacity"

															                 To="0" />
														</Storyboard>
													</BeginStoryboard>
												</DataTrigger.ExitActions>
											</DataTrigger>											
										</Style.Triggers>
									</Style>
								</Border.Style>



但是,如果用户在淡出控件时将鼠标移到控件上,我想暂停动画,以最大的不透明度显示控件,然后当鼠标离开该区域时,继续动画.

我已经尝试了一些方法,但是看不到如何在XAML中暂停动画.

为任何帮助喝彩

Larry



If the user moves their mouse over the control when it''s fading out however, I would like to pause the animation, display the control with maximum opacity and then when the mouse leaves the area, continue the animation.

I''ve tried a few things, but I can''t see how to pause an animation in XAML.

Cheers for any help

Larry

推荐答案

Larry;

我在MSDN中遇到了以下链接,该链接可能会有所帮助:

http://msdn.microsoft.com/en-us/library/system.windows.media.animation.pausestoryboard.aspx

页面底部的XAML示例是完全独立的,并且可以在Visual Studio 2010或Kaxamal http://www中正常运行. kaxamal.com

故事板的暂停和行为是通过绑定到各个Button单击的路由事件实现的,但是我认为它们可以绑定到任何鼠标事件.

至于恢复情节提要回放,在我认为是正确的默认行为的不停点击处获取不透明度,并将不透明度设置为100%可能需要附加的数据绑定,以便在恢复时将不透明度重新设置为100% .

我希望这对您有帮助,也很有趣,一旦您使用了XAML,我认为如果可以与我们分享您的结果将具有巨大的价值.
Hi, Larry;

I came across the following link in MSDN that may be of help:

http://msdn.microsoft.com/en-us/library/system.windows.media.animation.pausestoryboard.aspx

The XAML example at the bottom of the page is fully self-contained, and should work as is in either Visual Studio 2010 or in Kaxamal http://www.kaxamal.com

The storyboard pause and behaviors are implemented through a routed events bound to respective Button clicks, but I think they could be bound to any mouse event.

As for resuming the storyboard playback, having the opacity pick up where the pause click I would think is the correct default behavior, and to have the opacity set to 100% may require an additional data binding to set the opacity back to 100% when resumed.

I hope this was of help and of interest, and once you have the XAML working, I think it would be of tremendous value if you could share your results with us.


这篇关于在XAML中暂停动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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