比如下面使用Behavior的例子,需要参照:Microsoft.Expression.Interactions.dll。
<Window x:Class="VisualStudioBehavior.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
Name="Window"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="Hello world">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ei:CallMethodAction TargetObject="{Binding ElementName=Window}" MethodName="Alert" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</Window>
如果提示找不到Dll怎么办?
通过Visual studio installer可以找到:
安装成功之后就可以找到了: