2011-07-28 18 views
2
<i:Interaction.Triggers> 
    <i:EventTrigger EventName="DownloadStartedEvent"> 
     <ei:ControlStoryboardAction/> 
    </i:EventTrigger> 
<i:Interaction.Triggers> 

DownloadStartedEvent是我的ViewModel上的一些公共事件。當ViewModel上的DownloadStartedEvent被觸發時,我想在View上使用這個觸發器來啓動一個StoryBoard。有沒有辦法實現這一點?由ViewModel中的事件觸發的視圖中的ControlStoryboardAction

回答

1

當你的事件名稱綁定到DataContext的情況下,它應該工作(又名。您的視圖模型)

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

謝謝,你是對的!但現在我有另一個問題。我想在觸發器中使用,但我希望TaretObject是坐在視圖中的某個實例,怎麼做? –

+0

等一下,關於我的第一個問題,似乎它不起作用。 EventName參數似乎沒有任何影響。我可以將其刪除,並以任何方式觸發觸發器。 –

相關問題