views:

324

answers:

4

This has been bothering me for a while, maybe I am missing something.

The following throws an error with the commented attribute (expected >), but shouldn't I be able to do something like this?

<Label x:Name="Gaga"
               FontSize="20"
               <!--
               Content="{Binding SomethingThatIsEmptyAtDesignTime"}
                -->
               Content="LookAtMe!"
               />
+2  A: 

You can't use a comment like that inside an element.

This is true to all XML, not just XAML.

Take a look at the XML Comments specification, which explicitly disallows this kind of markup.

Oded
+6  A: 

Because XAML is XML-based, and XML doesn't allow comments inside other markup. It's unfortunate, I agree; XML commenting leaves much to be desired.

Josh Petrie
+1  A: 

http://www.w3.org/TR/REC-xml/#sec-comments

Comments can exist anywhere within the document, outside of other markup.

Hope that helps!

Ian P
A: 

No, you shouldn't. XML doesn't work that way - a comment node isn't an attribute, and so it can't go where attributes should be.

Hackles