wpf VisualState 与 wpfToolkit 冲突?

发布于 2024-10-19 05:30:13 字数 1957 浏览 3 评论 0原文

我正在 VS2010 中构建一个应用程序,使用 wpfToolkit 3.5 作为引用程序集。

我尝试从 ExpressionBlend 4 添加一些 VisualStates,但在尝试构建项目时收到以下错误。

类型“System.Windows.VisualState” 存在于两个“c:\Program Files”中 (x86)\参考 程序集\Microsoft\Framework.NETFramework\v4.0\PresentationFramework.dll' 和 'c:\Program Files (x86)\WPF 工具包\v3.5.50211.1\WPFToolkit.dll'

这是我也尝试过的代码

<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>

,但出现了同样的错误

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>

有什么建议吗?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里兽 2024-10-26 05:30:13

这就是外部别名的用途
http://msdn.microsoft.com/en-us/library/ms173212.aspx

您可以通过 Visual Studio 进行设置,方法是

  1. 右键单击 WPFToolkit 引用以查看其属性,
  2. 将“别名”字段更改为您喜欢的任何内容。

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.
梦幻的心爱 2024-10-26 05:30:13

我解决这个问题的方法是在此处获取源代码的副本,并修改它,使 VisualStateManager 和相关类位于不同的命名空间中(我选择 System.Windows.VSM) 这有点痛苦,但它会起作用。我预计 VSM 将从工具包的未来版本中删除,但我无法证明这一点。

同时,您还可以做一些其他事情,但每件事都有点痛苦+可能不起作用,具体取决于您的情况。

  1. 删除对 WPFToolkit 的依赖。您的代码可能需要它,所以这不会真正起作用。我很幸运,在我的一个项目中侥幸逃脱了惩罚。
  2. 等待 WPFToolkit 的下一个版本,并希望它能得到修复。谁知道什么时候会发生这种事,现在已经快一年了。
  3. 使用 Blend 3 或其他与您的工具包版本兼容的东西。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文