tags:

views:

251

answers:

1

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?

A: 

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.

HTH, Kent

Kent Boogaart
How do you "turn it off", I don't see it under tools | options | text editors | xaml for instance.
Edward Tanguay
You need to map the .xaml extension to the XML editor. It's in the options somewhere under File Extensions.
Kent Boogaart