How to Add System.Windows.Interactivity to Project

How to add System.Windows.Interactivity to project?

The official package for behaviors is Microsoft.Xaml.Behaviors.Wpf.

It used to be in the Blend SDK (deprecated).

See Jan's answer for more details if you need to migrate.

How to add the reference 'Microsoft.Expression.Interaction' and 'System.Windows.Interactivity' in visual studio 2019?

You have to replace the namespace for xmlns:i with xmlns:i="http://schemas.microsoft.com/xaml/behaviors".

Blend for Visual Studio SDK for .NET in VS2019

You can try these nuget packages:

Microsoft.Expression.Blend.SDK.WPF: Microsofts expression blend SDK for WPF (4.0)

Microsoft.SDK.Expression.Blend: Micosoft Expression Blend SDK for 4.5

Expression.Blend.Sdk: Contains System.Windows.Interactivity (4.0, 4.5)

They all wrap Blend SDK dlls into a nuget package.

ClickOnce requires System.Windows.Interactivity Version 4.5.0.0

Apparently, MVVM Light Toolkit installs a 4.5 version of System.Windows.Interactivity in the project, and that was conflicting with the 4.0 version. Solution:

  1. Expand project references.
  2. Locate System.Windows.Interactivity.
  3. Right-click it and choose Remove.
  4. Right-click References and choose Add Reference.
  5. Under Assemblies > Extensions, check the box for System.Windows.Interactivity version 4.5.0.0.
  6. Click OK to close the references.

Now publish again and the installer works fine. As part of the above research into what was causing the conflict, I enabled diagnostic output for the build, which generated a verbose log. On about line 2,000, it included this:

Unified Dependency "System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". (TaskId:13)
1> Using this version instead of original version "4.0.0.0" in "C:\Users\myUserName\Documents\Visual Studio 2015\Projects\MyProject\packages\Blend.Interctivity.WPF.v4.0.1.0.3\lib\net40\Microsoft.Expression.Interactions.dll" because of a binding redirect entry in the file "App.config". (TaskId:13)
1> Resolved file path is "C:\Users\myUserName\Source\Workspaces\Workspace\packages\MvvmLightLibs.5.2.0.0\lib\net45\System.Windows.Interactivity.dll". (TaskId:13)
1> Reference found at search path location "C:\Users\myUserName\Source\Workspaces\Workspace\packages\MvvmLightLibs.5.2.0.0\lib\net45". (TaskId:13)
1> For SearchPath "C:\Users\myUserName\Source\Workspaces\Workspace\packages\MvvmLightLibs.5.2.0.0\lib\net45". (TaskId:13)
1> Considered "C:\Users\myUserName\Source\Workspaces\Workspace\packages\MvvmLightLibs.5.2.0.0\lib\net45\System.Windows.Interactivity.winmd", but it didn't exist. (TaskId:13)
1> Required by "GalaSoft.MvvmLight.Platform, Version=5.2.0.37226, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL". (TaskId:13)
1> Required by "Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". (TaskId:13)
1> This reference is not "CopyLocal" because it conflicted with another reference with the same name and lost the conflict. (TaskId:13)
1> The ImageRuntimeVersion for this reference is "v4.0.30319". (TaskId:13)

Why System.Windows.Interactivity doesn't want to work?

This is the correct namespace for interactivity within XAML:

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

The assembly with display name 'System.Windows.Interactivity' failed to load

Looks to me like you are using the wrong version of the DLL. That DLL has a bunch of different versions floating around. You need the one for your version of .NET. Are you referencing the 4.5 version?

Compilation error for interactivity and interaction

You need to add references (Project->Add Reference->Assemblies in Visual Studio) to System.Windows.Interactivity.dll and Microsoft.Expressions.Interactions.dll.

They are part of the Blend SDK which can be downloaded from microsoft.com or by installing this NuGet package (Tools->Nuget Package Manager->Package Manager Console) into your project.

Frameworks which provide Behavior T in .NET Core 3 / WPF

I realised my question was a bit thick as these packages are Open Source...

So I've solved the problem by cloning microsoft/XamlBehaviorsWpf and including the source for Behavior and dependencies in my .NET Core 3 application.



Related Topics



Leave a reply



Submit