MVVM- 在 Silverlight 中的视图模型中触发情节提要 [英] MVVM- Trigger Storyboard in the View Model in Silverlight
问题描述
在我看来,如果可能,我想从 ViewModel 触发几个故事板.有没有一种简单的方法或优雅的方法来做到这一点.这就是我想要做的.
I have a couple of Storyboards in my view that I would like to trigger from the ViewModel if possible. Is there a simple way or elegant way of doing this. Here is what I am trying to do.
人点击按钮-->RelayCommand(在ViewModel中),然后Relay Command应该播放故事板.还有一件事,我还想在没有任何交互的情况下在 ViewModel 中自行触发故事板动画.
Person Clicks on a Button-->RelayCommand (In the ViewModel), the Relay Command should then play the storyboard. Also one more thing, I would like to also trigger the storyboard animation by itself in the ViewModel without any interaction.
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<cmd:EventToCommand Command="{Binding ButtonPress}" CommandParameterValue="RedButtonLight">
</cmd:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers>
推荐答案
我知道这是很久以前的事了.但我写了一篇关于触发故事板和 MVVM 的详细博客文章.
I know it's a long time ago. But I've written a detailed blog post about Triggering Storyboards and MVVM.
http://mark.mymonster.nl/2010/12/14/trigger-a-storyboard-on-viewmodel-changes/
这篇关于MVVM- 在 Silverlight 中的视图模型中触发情节提要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!