Why can’t I comment attributes in XAML?

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.

Leave a Comment

tech