Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

wpf - Why would my XAML editor be giving me an error but the project compiles and runs fine?

I've implemented the Attached Behavior Command pattern which compiles and runs fine, but strangely my XAML editor is giving the error:

The attachable property 'Behaviors' was not found in type 'CommandBehaviorCollection'.

in this XAML:

   <c:CommandBehaviorCollection.Behaviors>
        <c:BehaviorBinding Event="MouseLeftButtonDown" 
                           Command="{Binding PressedLeftButton}"
                           CommandParameter="MainBorder123"/>
        <c:BehaviorBinding Event="MouseRightButtonDown" 
                           Command="{Binding PressedRightButton}"
                           CommandParameter="MainBorder123"/>
    </c:CommandBehaviorCollection.Behaviors>

However, I can compile and run it fine.

I've rebuilt the project, the solution, closed and opened it, but the XAML editor still gives me this error.

Has anyone experienced an incongruity between XAML editor and compiler like this before? Any idea how to make the XAML editor see that there really isn't a problem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes. I normally turn the XAML Editor off and use the XML Editor instead. It's faster and doesn't throw these red herring "errors" at you. I haven't had a chance to try it yet, but hopefully VS2010 does a much better job in this area.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...