views:

25

answers:

1

Let's say we have the below code:

<Window 
    x:Class="Consus.Client.UI.Sandbox.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"

    x:Name="RibbonWindow"
    Width="800" Height="600"
    MinWidth="800" MinHeight="600"
    Title="MainWindow">

And we want to add a comment at the line MinWidth="800" MinHeight="600" to say "This is the minimum width/height of the application". I tried:

<Window 
        x:Class="Consus.Client.UI.Sandbox.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"

        x:Name="RibbonWindow"
        Width="800" Height="600"
        MinWidth="800" MinHeight="600" <!--My comment goes here-->
        Title="MainWindow">

But this raised an error. So how can I do that?

+2  A: 

It's not possible to add an comment to an attribute in this manner. XAML is an XML dialect and hence follows the syntatic rules of XML which dissallow this. XML comments can only appear outside of other markup elements (or more simply outside of other XML element tags).

The closest place it can be added is before or after the <Window> element.

<!-- Legal --> 
<Window
  ...

> <!-- Legal -->
JaredPar