当前位置:首页 > 操作系统 > Windows

WPF System.Windows.Interactivity 使用示例

System.Windows.Interactivity 用于绑定多个事件,类似于多个触发器(MultiTrigger)

在Nuget搜索System.Windows.Interactivity下载安装到项目中

在XAML中引用

引用方式一:

xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

引用方式二:

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

示例一:Button的多个事件(命令)

<Button Name="btn" Content="绑定多个Command">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Click">
            <i:InvokeCommandAction Command="{Binding Command1}" CommandParameter="1" />
        </i:EventTrigger>
        <i:EventTrigger EventName="MouseMove">
            <i:InvokeCommandAction Command="{Binding Command2}" CommandParameter="{Binding ElementName=btn}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</Button>

原文:https://www.cnblogs.com/microsoft-zh/p/14767807.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐