在WPF / MVVM视图模型开始动画 [英] Starting an animation from the ViewModel in WPF/MVVM

查看:248
本文介绍了在WPF / MVVM视图模型开始动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个应用MVVM并已开始投入几动画。我想呼吁的ViewModel东西开始故事板。 这个博客有前途的方法给它,但它实际上并没有工作。该IDChanged处理程序永远不会触发出于某种原因。

I'm writing a MVVM app and have started putting in a few animations. I want to call something on the ViewModel which starts the a storyboard. This blog had a promising approach to it, but it doesn't actually work. The IDChanged handler never fires for some reason.

我还发现,你可以在EventTriggers启动动画,但我不知道如何提高一个在视图模型。

I also found that you could start animations on EventTriggers, but I don't know how to raise one on the ViewModel.

推荐答案

我最终加入AnimationStarted事件对我的ViewModel有什么动画是一个关键的字符串。然后在我编程方式创建动画视图,订阅AnimationStarted事件,踢适当的动画关闭时触发。

I ended up adding an AnimationStarted event to my ViewModel with a key string for what animation it is. Then on the view I create the animation programmatically, subscribe to the AnimationStarted event, and kick the appropriate animation off when it fires.

这篇关于在WPF / MVVM视图模型开始动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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