开发者

wpf VisualState conflicts with wpfToolkit?

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开发者_如何学JAVA 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

  1. Right click on the WPFToolkit reference to view its properties,
  2. 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.

  1. 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.
  2. Wait for the next release of WPFToolkit, and hope it gets fixed. Who knows when this will happen, its been almost a year now.
  3. Use blend 3, or something else that is compatible with your version of the Toolkit.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜