Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I comment attributes in XAML?

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!"                /> 
like image 720
Erik Kerber Avatar asked Jan 15 '10 16:01

Erik Kerber


People also ask

How do I comment multiple lines in XAML?

If you are using Eclipse IDE you can comment out lines in an XML file by highlighting them and press Ctrl+Shift+c.

What is attributes in XAML?

Attribute syntax is the XAML markup syntax that sets a value for a property by declaring an attribute on an existing object element. The attribute name must match the CLR member name of the property of the class that backs the relevant object element.


1 Answers

Though you can't comment out using the basic XAML markup, you can achieve the desired results by importing the Open XML markup namespace.

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ignore="http://www.galasoft.ch/ignore" mc:Ignorable="ignore"  <Label x:Name="Gaga"        FontSize="20"        ignore:Content="{Binding SomethingThatIsEmptyAtDesignTime}"        Content="LookAtMe!" /> 

This blog post describes how to do it.

like image 119
Erik Kerber Avatar answered Sep 21 '22 09:09

Erik Kerber