Comments in XAML

Just like code, often you want to add comments to your XAML to describe what it's for, and also comment out bits of XAML without having to delete it from the file. Let's look at some strategies for using comments in XAML.

Commenting Out Elements

You can use the standard XML tags, which are incidentally the same as HTML's, for inserting comments into your XAML. Begin the comment with <!--, and end it with -->, for example:

<!-- A XAML comment -->

At times, you might also want to comment out some XAML (instead of deleting it), for example:

<!-- <TextBlock Text="{Binding Name}" /> -->

images Note As a shortcut, use the key chord ...

Get Pro Business Applications with Silverlight 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.