Ambiguous type reference. A type named `VisualState` occurs in at least two namespaces

后端 未结 1 378
有刺的猬
有刺的猬 2021-01-01 08:50

What is the following error?

Ambiguous type reference. A type named \'VisualState\' occurs in at least two namespaces, \'System.Windows\' and \'System

相关标签:
1条回答
  • 2021-01-01 09:49

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

    you can resolve the error using following imports in your xaml

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

    instead of using

    <VisualState x:Name="Pressed">
                                            <Storyboard>
    
                                            </Storyboard>
                                        </VisualState>
    

    Use:

    <vsm:VisualState x:Name="Pressed">
                                        <Storyboard>
    
                                        </Storyboard>
                                    </vsm:VisualState>
    
    0 讨论(0)
提交回复
热议问题