简体   繁体   中英

Visual Studio 2017 - What happened to Expression interactions?

I make extensive use of Expression interactions' CallMethodAction to handle events from XAML in a MVVM-friendly way.

I have just created a new WPF project in VS2017 and now I see the old Expression namespace is gone. I found this page on MSDN which is the action I'm looking for but after referencing that assembly and adding the namespace it does not contain the CallMethodAction. That page is for Silverlight and this is WPF, so I'm concerned that action is no longer available.

So does anyone know if it has in fact been removed/replaced? How is one supposed to call event handlers on the viewmodel now?

(I do know about InvokeCommandAction, but I prefer CallMethodAction since it relays the original event arguments, and allows for canceling preview events.)

Edit : Just to move forward I tried InvokeCommandAction but it no longer works the same way either and I cannot find any documentation on the new usage.

I did find this reference on MSDN for the Microsoft.Xaml.Interactions namespace which appears to contain the classes I need, but that assembly doesn't appear to exist.

I feel like I'm missing something obvious here. I don't see how they could make a breaking change to something as basic as responding to events.

使用 Visual Studio 2017 安装程序安装“Blend for Visual Studio SDK for .NET”,您可以在“独立组件”页面的“SDK、库和框架”标题下找到该安装程序。

A little update as for 2020:

As mentioned by Jan in other question :

Microsoft open-sourced XAML Behaviours and posted a blog post how to update to this version.

Steps to proceed with update:

  1. Remove reference to “Microsoft.Expression.Interactions” and “System.Windows.Interactivity”.
  2. Install the Microsoft.Xaml.Behaviors.Wpf NuGet package.
  3. XAML files – replace the xmlns namespaces http://schemas.microsoft.com/expression/2010/interactivity and http://schemas.microsoft.com/expression/2010/interactions with http://schemas.microsoft.com/xaml/behaviors
  4. C# files – replace the usings in c# files “Microsoft.Xaml.Interactivity” and “Microsoft.Xaml.Interactions” with “Microsoft.Xaml.Behaviors”

CallMethodAction is defined in Microsoft.Expressions.Interactions.dll. This assembly is not part of the .NET Framework but you can download it using NuGet:https://www.nuget.org/packages/MicrosoftExpressionInteractions/

And the InvokeCommandAction class is defined in System.Windows.Interactivity.dll assembly: https://www.nuget.org/packages/System.Windows.Interactivity.WPF/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM