由ViewModel中的事件触发的View中的ControlStoryboardAction

时间:2011-07-28 23:24:49

标签: silverlight-4.0 mvvm eventtrigger

<i:Interaction.Triggers>
   <i:EventTrigger EventName="DownloadStartedEvent">
       <ei:ControlStoryboardAction/>
   </i:EventTrigger>
<i:Interaction.Triggers>

DownloadStartedEvent是我的ViewModel上的一些公共事件。我希望View上的这个触发器在ViewModel上的DownloadStartedEvent被触发时启动一个StoryBoard。有没有办法实现这个目标?

1 个答案:

答案 0 :(得分:1)

将EventName绑定到DataContext的事件(也称为您的viewmodel)时,它应该可以正常工作

<i:Interaction.Triggers>
  <i:EventTrigger EventName="{Binding DownloadStartedEvent}">
   <ei:ControlStoryboardAction/>
  </i:EventTrigger>
<i:Interaction.Triggers>