问题
Consider this piece of XML:
<ListBox x:Name="pictureBox"
ItemsSource="{Binding}"
MouseDoubleClick="item_DoubleClick"
>
Is there any way to comment out MouseDoubleClick="item_DoubleClick"
? This attempt fails:
<ListBox x:Name="pictureBox"
ItemsSource="{Binding}"
<!-- MouseDoubleClick="item_DoubleClick"-->
>
回答1:
You could just comment out the whole element, which would work, and underneath it put the modified version without that attribute.
回答2:
No it's not you'll have to remove it. You cannot have comments inside the declaration of an Element. It would not be possible for the parser to parse this XML at all because of the additional "<" sign inside the open declaration of ListBox Element.
来源:https://stackoverflow.com/questions/5244187/commenting-out-xml