I am building an application in VS2010 with wpfToolkit 3.5 as referenced assembly.
I tried to add some VisualStates from ExpressionBlend 4 and I am getting the following error when I am trying to build the project.
The type 'System.Windows.VisualState' exists in both 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\PresentationFramework.dll' and 'c:\Program Files (x86)\WPF Toolkit\v3.5.50211.1\WPFToolkit.dll'
this is the 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 also and this but the same error occured
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
This is what extern alias is for http://msdn.microsoft.com/en-us/library/ms173212.aspx
You can set this up through Visual studio by
- Right click on the WPFToolkit reference to view its properties,
- Change the "alias" field to anything you like.
The way that I have resolved this problem is to get a copy of the source code here, and modify it so that the VisualStateManager and related classes are in a different namespace (I chose System.Windows.VSM) It is kind of a pain, but it will work. I expect that the VSM will be removed from future versions of the toolkit but I can't prove it.
Meanwhile, there are a couple of things other that you can do, and each of them are kind of a pain + probably won't work, depending on your case.
- Drop the dependency to WPFToolkit. Your code probably needs it, so this won't really work. I was lucky and got away with it on one of my projects.
- Wait for the next release of WPFToolkit, and hope it gets fixed. Who knows when this will happen, its been almost a year now.
- Use blend 3, or something else that is compatible with your version of the Toolkit.
来源:https://stackoverflow.com/questions/5108334/wpf-visualstate-conflicts-with-wpftoolkit