Tuesday, May 22, 2007

Commenting XAML elements

Normally if you want to comment a particular element (Button.Content)in the tag like the below one,usually select the element and select the comment option from VS toolbar or menu.
This works with c# code .But wont with xaml.It produces a compilation error.

<Button Name="btn" Content="Hai" Click="clicked"/>

TO get rid of this use as follows

<Window x:Class="BlendControl.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="BlendControl"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:c="Comments"
mc:Ignorable="c"
>
<StackPanel >
<Button Name="btn" c:Content="Hai" Click="clicked"/>
</StackPanel>
</Window>

This nicely comment the Content element.

No comments:

Post a Comment