WPF 通过行为将事件绑定到命令
2016-11-30 20:29
459 查看
dll:Microsoft.Expression.Interactions.dll
System.Windows.Interactivity.dll
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Behavior"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:pi="http://schemas.microsoft.com/prototyping/2010/interactivity"
x:Class="Behavior.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="grid">
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Height="17.5" Margin="141,73.5,0,0" VerticalAlignment="Top" Width="47.5">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<i:InvokeCommandAction Command="{Binding Path= EnterCommand}"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<i:InvokeCommandAction Command="{Binding Path=LeaveCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</Window>
System.Windows.Interactivity.dll
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Behavior"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:pi="http://schemas.microsoft.com/prototyping/2010/interactivity"
x:Class="Behavior.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="grid">
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Height="17.5" Margin="141,73.5,0,0" VerticalAlignment="Top" Width="47.5">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<i:InvokeCommandAction Command="{Binding Path= EnterCommand}"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<i:InvokeCommandAction Command="{Binding Path=LeaveCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</Window>
相关文章推荐
- wpf样式绑定 行为绑定 事件关联 路由事件实例
- 【2016-11-15】【坚持学习】【Day26】【WPF 命令绑定到事件】
- WPF 在事件中绑定命令
- WPF Control Hints - ContextMenu : 怎么通过MenuItem的Click事件取得ContextMenuItem绑定的类实例?
- WPF 在事件中绑定命令(不可以在模版中绑定命令)
- WPF 在事件中绑定命令
- WPF Prism框架下基于MVVM模式的命令、绑定、事件
- 将命令绑定到事件中(WPF)
- 了解 WPF 中的路由事件和命令(MSDN)
- gridview绑定checkbox控件后,通过单击CheckedChanged事件获取当前选择行的数据
- WPF中的命令与命令绑定
- WPF利用通过父控件属性来获得绑定数据源RelativeSource
- 【转】通过在RowDataBound事件中把行索引绑定到控件的CommandArgument,然后在RowCommand事件中取出
- WPF学习系列032: 3.4.3 带有内建命令绑定的控件
- 通过Code Behind的方式,为DataGrid内的Button绑定事件
- WPF中的EventTrigger和命令绑定
- MVVM之旅-给任意的事件绑定命令(Adventures in MVVM – Binding Commands to ANY Event)
- WPF中的命令与命令绑定——出自《IT168》
- WPF中的命令与命令绑定——出自《IT168》
- WPF学习之【事件,命令和设置】