Why can't I comment attributes in XAML?

Viewed 9630

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!"
               />
7 Answers

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.

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.

Related