2011-08-18 29 views
0

如何組合兩個活動並創建新活動?wpf聯合活動

例如:如果鼠標離開控件並將焦點放在另一個控件上(使焦點丟失),則觸發事件custom_event。

我是WPF新手,我還沒有完成wpf的禪宗。如果還有其他方法可以做到這一點,請告訴我。

+0

特定控制的LostFocus事件已經爲你做這個例子。 – CharithJ

+0

LostFocus在用戶控件上無法正常工作。 – icaptan

回答

2

有可能在XAML與MultiDataTriggers,看到這個article from Josh Smith:

<!-- This MultiDataTrigger affects losers of the race. --> 
<MultiDataTrigger> 
    <MultiDataTrigger.Conditions> 
    <Condition Binding="{Binding IsFinished}" Value="True" /> 
    <Condition Binding="{Binding IsWinner}" Value="False" /> 
    </MultiDataTrigger.Conditions> 

    <!-- Apply the "finished the race" brush to 
     the horse's progress indicator. --> 
    <Setter TargetName="progressIndicator" 
      Property="Fill" Value="{StaticResource FinishedBrush}" /> 

    <!-- Fade the race pit in and out if the horse lost the race. --> 
    <MultiDataTrigger.EnterActions> 
    <!-- Fade away the RaceHorse's Border element when it loses a race. --> 
    </MultiDataTrigger.EnterActions> 

    <MultiDataTrigger.ExitActions> 
    <!-- Fade in the RaceHorse's Border element when a new race starts. --> 
    </MultiDataTrigger.ExitActions> 
</MultiDataTrigger> 
+0

感謝您的答案,我不能選擇答案作爲缺乏聲譽的真正原因,所以我記起了upvoted。現在我可以:)謝謝! (我在我的信息頁面上方看到一個紅色的句子,感謝您的警告) – icaptan