C# 我们可以在 WPF MVVM 中使用 <i:Interaction.Triggers>(不在 Silverlight 中)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17750081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
can we use <i:Interaction.Triggers> in WPF MVVM (not in Silverlight)
提问by user2600034
Can I use <Interaction.Triggers />
in WPF MVVM rather than in Silverlight.
我可以<Interaction.Triggers />
在 WPF MVVM 而不是 Silverlight 中使用吗?
All the examples I have come across show the use of <Interaction.Triggers />
in Silverlight.
我遇到的所有示例都显示了<Interaction.Triggers />
在 Silverlight 中的使用。
How can I use it in WPF? I am using MVVM model.
如何在 WPF 中使用它?我正在使用 MVVM 模型。
回答by Nitesh
Add a reference to the assembly System.Windows.Interactivity
添加对程序集 System.Windows.Interactivity 的引用
then declare it in XAML as
然后在 XAML 中将其声明为
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
or use it if you have Blend SDK installed
或者如果你安装了 Blend SDK 就使用它
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
and use it in XAML as
并在 XAML 中使用它作为
<i:Interaction.Triggers>
<i:EventTrigger>
</i:EventTrigger>
</i:Interaction.Triggers>