Aku digunakan sintaks ini karena saya menemukan online tapi melempar kesalahan:
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<!-- Cool comment -->
xmlns:System="clr-namespace:System;assembly=mscorlib"
'Nama tidak dimulai dengan '<' karakter, nilai heksadesimal 0x3C. Line 4, posisi 5.' XML adalah tidak sah.
Saya berasumsi mereka XAML deklarasi namespace yang di tag induk dari kendali anda? Anda dapat't menempatkan komentar dalam tag lain. Selain itu, sintaks anda're menggunakan adalah benar.
<UserControl xmlns="...">
<!-- Here's a valid comment. Notice it's outside the <UserControl> tag's braces -->
[..snip..]
</UserControl>
Ditemukan sebuah solusi yang bagus oleh Laurent Bugnion, hal ini dapat terlihat seperti ini:
<UserControl xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:comment="Tag to add comments"
mc:Ignorable="d comment" d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Button Width="100"
comment:Width="example comment on Width, will be ignored......">
</Button>
</Grid>
</UserControl>
Berikut ini's the link: http://blog.galasoft.ch/posts/2010/02/quick-tip-commenting-out-properties-in-xaml/
Commenter di link yang disediakan karakter tambahan untuk mengabaikan awalan pengganti menyoroti:
mc:Ignorable=”ØignoreØ”
Anda dapat't menyisipkan komentar di dalam tag xml.
Buruk
<Window xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<!-- Cool comment -->
xmlns:System="clr-namespace:System;assembly=mscorlib">
Baik
<Window xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib">
<!-- Cool comment -->
Bagi siapa pun yang mempelajari hal ini, komentar yang lebih penting, sehingga gambar pada Xak diam-diam's ide
(dari User500099's link) untuk Properti Tunggal komentar, tambahkan ini di atas kode XAML blok:
<!--Comments Allowed With Markup Compatibility (mc) In XAML!
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ØignoreØ="http://www.galasoft.ch/ignore"
mc:Ignorable="ØignoreØ"
Usage in property:
ØignoreØ:AttributeToIgnore="Text Of AttributeToIgnore"-->
Kemudian di blok kode
<Application FooApp:Class="Foo.App"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ØignoreØ="http://www.galasoft.ch/ignore"
mc:Ignorable="ØignoreØ"
...
AttributeNotToIgnore="TextNotToIgnore"
...
...
ØignoreØ:IgnoreThisAttribute="IgnoreThatText"
...
>
</Application>
Anda tidak dapat menempatkan komentar dalam UWP XAML kategori. Anda sintaks yang benar.
YANG HARUS DILAKUKAN:
<xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib"/>
<!-- Cool comment -->
UNTUK TIDAK MELAKUKAN:
<xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<!-- Cool comment -->
xmlns:System="clr-namespace:System;assembly=mscorlib"/>