命令

1.添加引用

- Microsoft.Expression.Interactions.dll

-System.Windows.Interactivity

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"


2.命令分类

<Button Content="Submit Method"  Width="180">
     <i:Interaction.Triggers>

         <!--传递事件参数-->
         <i:EventTrigger EventName="Click">
               <ei:CallMethodAction TargetObject="{Binding}" MethodName="SubmitClicked"/>
         </i:EventTrigger>

         <!--传递自定义参数-->
         <i:EventTrigger EventName="KeyUp">
             <i:InvokeCommandAction Command="{Binding WindowKeyCommand}" CommandParameter="{Binding ElementName=txtCardNo}"/>
         </i:EventTrigger>

         <!--传递多个参数-->
         <i:EventTrigger EventName="KeyDown">
             <i:InvokeCommandAction Command="{Binding WindowKeyCommand}" >
                 <i:InvokeCommandAction.CommandParameter >
                     <MultiBinding Converter="{StaticResource buttonMultiValueConverter}">                     
                         <Binding ElementName="button1" />                     
                         <Binding ElementName="button2" />
                     </MultiBinding>
                 </i:InvokeCommandAction.CommandParameter>
             </i:InvokeCommandAction>
         </i:EventTrigger>
     </i:Interaction.Triggers>
</Button>

posted @ 2023-10-19 16:51  zhangxiuju  阅读(43)  评论(0)    收藏  举报