WPF运行错误:Ambiguous type reference. A type named 'VisualState' occurs in at least two namespaces...

This error(most of the time warning) will occur when using two or more references which contains same namespace and classes. in your case you are using VisualState which is part of PresentationFramework assembly and you might have added another assembly which contains same "VisualState" object with the same namespace "System.Windows" .

该错误产生的原因是,两个或两个以上的引用包含相同的命名空间和类,我的程序中使用的VisualState是PresentationFramework数据源的一部分,同时程序中又添加了另外一个数据源,该数据源同样包含了命名空间System.Windows和VisualState对象。

修改办法:引入PresentationFramework命名空间

xmlns:vsm ="clr-namespace:System.Windows;assembly=PresentationFramework" 

有错误的代码:

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver"/>

将以上代码替换成:

<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualState x:Name="Normal"/>
<vsm:VisualState x:Name="MouseOver"/>

错误立刻消失不见了,呵呵!


转载于:https://www.cnblogs.com/shuijing-411/archive/2011/10/13/WPF.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值