6

I have to use VisualStateManager class in my WPF window, but as I have referenced the assemblies of both WPF Toolkit and PresentationFramework.dll in my project, C# is not able to resolve the VisualStateManager class and gives the compile error like - "The type exists in both 'PresentationFramework.dll' and 'WPFToolkit.dll'" and I am not able to proceed.

How to tell C# compiler to use VisualStateManager class from either of the assemblies and get the project to compile successfully?

S2S2
  • 8,322
  • 5
  • 37
  • 65

3 Answers3

6

Since the .NET4.0, the WPF Toolkit has been included in the framework. You should be able to remove WPF Toolkit, update some namespaces and the application still compile.

This is an approach we have taken in a project where we recently upgraded from .NET3.5 to .NET 4.0

Best regards,

Dr. Andrew Burnett-Thompson
  • 20,980
  • 8
  • 88
  • 178
  • 1
    Only /parts/ of the WPF Toolkit have been moved into the .NET 4.0 framework. VisualStateManager is one that has been moved, but as an example, Accordion is still only available in WPF Toolkit. – kitti Feb 03 '12 at 22:53
  • 1
    True, but as the question referred to VSM its still the correct answer – Dr. Andrew Burnett-Thompson Feb 04 '12 at 14:41
0

I had a similar problem, not to do with the VisualStateManager but with the TemplateVisualStateAttribute I was using for one of my custom classes.

Changing the WPFToolkit project reference alias fixed this for me, as per this question

Community
  • 1
  • 1
Almund
  • 5,695
  • 3
  • 31
  • 35
0

I ran into the same problem, I can not remove the ToolKit because I need the AutoCompleteBox control, and I don not want to include and modify the toolkit source code; so the solution I used was using an extern alias for the toolkit reference.

To do this in Visual Studio right click on the WPFToolkit reference and select properties >> then change the "alias" field to WpfToolKit or any alias of your choice.

Mohammed A. Fadil
  • 9,205
  • 7
  • 50
  • 67