有没有办法注释掉包含注释的 XAML? [英] Is there a way to comment out XAML that contains comments?

查看:62
本文介绍了有没有办法注释掉包含注释的 XAML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 WPF 和使用 XAML 还很陌生.如果突出显示的部分已经包含一些注释,我无法选择一大块 XAML 并在 Visual Studio 2010 中使用工具栏中的注释按钮将其注释掉,这让我感到非常沮丧.

I am fairly new to WPF and using XAML. I get really frustrated that I can not select a chunk of XAML and comment it out in Visual Studio 2010 using the comment button in the toolbar if the highlighted section already includes some comments.

其他语言允许您在评论中嵌套评论而不会出现问题.有没有办法使用 Visual Studio 2010 在 XAML 中注释掉注释?

Other languages allow you to nest comments inside of comments with no issue. Is there a way to comment out a comment in XAML using Visual Studio 2010?

推荐答案

不,XAML 中无法嵌套注释.

No, there is no way of having nested comments in XAML.

您可以在根元素上使用 mc:Ignorable 属性,任何以该值为前缀的属性或元素都将被忽略,例如:

You could use the mc:Ignorable attribute on your root element, and any attribute or element prefixed with that value will be ignored E.g:

<UserControl ...
   mc:Ignorable="i">

   <!-- Ignore Text attribute -->
   <TextBlock i:Text="Hello" />

   <!-- Ignore entire button -->
   <i:Button>
   </i:Button>

</UserControl>

请注意,blend 将 mc:Ignorable 属性值设置为d",因此您需要使用例如mc:Ignorable="d i"

Note that blend sets the mc:Ignorable attributes value to 'd', so you'll need to use e.g. mc:Ignorable="d i"

这篇关于有没有办法注释掉包含注释的 XAML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆