can we use in WPF MVVM (not in Silverlight) [c

2019-01-31 13:53发布

问题:

Can I use <Interaction.Triggers /> in WPF MVVM rather than in Silverlight.

All the examples I have come across show the use of <Interaction.Triggers /> in Silverlight.

How can I use it in WPF? I am using MVVM model.

回答1:

Add a reference to the assembly System.Windows.Interactivity

then declare it in XAML as

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

or use it if you have Blend SDK installed

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

and use it in XAML as

<i:Interaction.Triggers>
    <i:EventTrigger>

    </i:EventTrigger>
</i:Interaction.Triggers>


标签: c# wpf mvvm