添加引用
System.Windows.Interactivity
Microsoft.Expression.Interactions
引入
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
在控件上使用
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding ViewLoadCommand}" /> <!--绑定到命令上-->
<ei:CallMethodAction MethodName="View_Load" TargetObject="{Binding}" /> <!--直接绑定事件-->
</i:EventTrigger>
</i:Interaction.Triggers>