Wpf VisualState conflicts with wpfToolkit?

I am building an application in VS2010 using wpfToolkit 3.5 as a reference assembly.

I tried to add some VisualStates from ExpressionBlend 4, and I get the following error when I try to build a project.

The type "System.Windows.VisualState" exists in both files c: \ Program Files (X86) \ Assembly Link \ Microsoft \ Framework.NETFramework \ v4.0 \ PresentationFramework.dll and 'c: \ Program Files (x86) \ WPF Toolkit \ v3.5.50211.1 \ WPFToolkit.dll '

this is code

<VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="ShowHideRoomNumber"> <VisualState x:Name="Show"/> <VisualState x:Name="Hide"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="comboBox"> <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> 

I tried this too, but the same error occurred

 xmlns:vsm="clr-namespace:System.Windows;assembly=WPFToolkit" <vsm:VisualStateManager.VisualStateGroups> <vsm:VisualStateGroup x:Name="ShowHideRoomNumber"> <vsm:VisualState x:Name="Show"/> <vsm:VisualState x:Name="Hide"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="comboBox"> <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </vsm:VisualState> </vsm:VisualStateGroup> </vsm:VisualStateManager.VisualStateGroups> 

Any suggestions?

thanks

+4
source share
2 answers

This is what extern alias is for http://msdn.microsoft.com/en-us/library/ms173212.aspx

You can install this through Visual studio with

  • Right-click the WPFToolkit link to view its properties.
  • Change the alias field to whatever you like.
+10
source

The way I solved this problem is to get a copy of the source code here and change it so that the VisualStateManager and its related classes are in a different namespace (I chose System.Windows.VSM). This is a kind of pain, but it will work. I expect VSM to be removed from future versions of the toolkit, but I cannot prove it.

Meanwhile, there are a few things you can do, and each one is a pain +, it probably won’t work, depending on your case.

  • Drop dependency on WPFToolkit. Your code probably needs this, so this will not work. I was lucky and went with him to one of my projects.
  • Wait for the next release of WPFToolkit and hope that it will be fixed. Who knows when this will happen, its almost a year later.
  • Use blend 3 or something else that is compatible with your version of Toolkit.
+3
source

Source: https://habr.com/ru/post/1341181/


All Articles