设计时错误 - '的VisualState“发生在至少两个命名空间错误、两个、发生在、空间

2023-09-03 00:06:48 作者:菰獨者

我收到以下错误

暧昧的型号。至少有两个名字空间,System.Windows和System.Windows一个名为'的VisualState类型出现。考虑调整组件XmlnsDefinition属性。的

我不引用任何这些组件的命名空间的直接,我做了以下内容:

I am not referencing any of these assembly name spaces directly, I am doing the following:

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   

应用程序编译罚款,只是在设计时抛出这些错误。这发生在一些其它类是VSM的文库的一部分。

The application compiles fine, just throwing these errors at design time. This happens to a few other classes that are a part of the VSM library.

推荐答案

这听起来像你要使用编译WPF3.5与WPF4的WpfToolkit。该 VisualStateManager 现在WPF4的一部分,因此,如果您使用的工具包为的DataGrid VisualStateManager ,你可以简单地删除工具包参考来解决不确定性。如果你想使用该工具包的图表,那么你就应该用图表的WPF4版本:

It sounds like you are trying to use the WpfToolkit compiled for WPF3.5 with WPF4. The VisualStateManager is now part of WPF4, so if you are using the toolkit for the DataGrid or VisualStateManager, you can simply remove the toolkit reference to resolve the ambiguity. If you want to use the toolkit for charting, then you should be using the WPF4 version of charting:

的Silverlight / WPF的数据可视化开发推出4

如果你仍然需要使用旧的工具包与WPF4,你必须找到所有的XAML引用的VisualStateManager和相关类和preFIX他们针对特定组件的命名空间包含 System.Windows.VisualStateManager 要在以解决歧义使用。

If you still need to use the old Toolkit with WPF4, you'll have to find all the XAML references to the VisualStateManager and related classes and prefix them with a namespace targeting the specific assembly that contains the System.Windows.VisualStateManager you want to use in order to resolve the ambiguity.