kurze Antwort: weil ein <
Char zwischen <
und >
(durch XML-Definition) nicht erlaubt ist.
Die nächste Frage sollte sein: "Wie kann ich ein XML/XAML-Attribut Kommentar out"
Die Lösung (zum Beispiel in MS-Mischung/Visual Studio) ist ein mc:Ignorable
Attribut.
<RootElement
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DataContext="this is an attribute for design time only"
>
Also, wenn Sie einen Kommentar hinterlassen wollen, fügen Sie einfach d:
Präfix auf das Attribut
Um mehr nützlich Sie mehr als ein vernachlässigbares Präfix haben:
<RootElement
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d ="http://schemas.microsoft.com/expression/blend/2008"
xmlns:rem ="http://schemas.microsoft.com/expression/blend/2008"
xmlns:TODO ="http://schemas.microsoft.com/expression/blend/2008"
xmlns:DISABLED ="http://schemas.microsoft.com/expression/blend/2008"
xmlns:NOTE ="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d rem TODO DISABLED NOTE"
d:Foo="this is ignored (design time only attribute)"
rem:Background="this is also ignored (commented out)"
TODO:Background=" (commented as TODO)"
DISABLED:Background="this is also ignored (commented as DISABLED)"
>
Die „Token“ rem
TODO
DISABLED
NOTE
sind nur Vorschläge von mir und andere (gültige XML-Namen) sind möglich.
praktische Probe in jedem Element:
<TextBox
DISABLED:Background="#FF000000" NOTE:Background="temporary disabled"
Background="#FFFFFF" TODO:Background="specify an other background"
TODO:TextBox="complete the textbox"
>
Verwendung von Unicode-Zeichen:
Die folgende Liste von Unicode-Zeichen sind gültig für XML name:
ᆞ
ᅳ
ǀ
ǁ
ǂ
ǃ
ᅀ
<TextBox
ǃ:Background="temporary disabled"
ǂ:Background="temporary disabled"
ǁ:Background="temporary disabled"
>
Verwendung als Dokumentation (XML Kommentare)
<RootElement
...
xmlns:doc="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="... doc ..."
<MyControl
doc.summary="shows my control"
doc.remarks="any remarks..."
/>
>
WPF: Ein Schritt vorwärts, zwei Schritte zurück. Es ist alles über WPF, nicht wahr? –