Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to comment out XAML that contains comments?

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.

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?

like image 703
tmoltzan Avatar asked Dec 17 '10 21:12

tmoltzan


People also ask

How do I comment multiple lines in XAML?

If you are using Eclipse IDE you can comment out lines in an XML file by highlighting them and press Ctrl+Shift+c.

How do you comment code on xamarin?

Try Ctrl + K, Ctrl + C. On windows, this is the shortcut for commenting code both for C# and XAML.


1 Answers

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

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> 

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

like image 57
devdigital Avatar answered Sep 30 '22 12:09

devdigital