Reputation: 6518
/// <summary>
///
/// </summary>
/// <remarks
///
/// </remarks>
How to add xaml code in above comment, avoiding code parser to create links that do not exist (CTRL + Click messages)?
Upvotes: 4
Views: 2210
Reputation: 55956
You have two options:
Standard XML escaping
/// <TextBlock Text="Hello World!"/>
CDATA sections
/// <![CDATA[<TextBlock Text="Hello World!"/>]]>
With the first option, Visual Studio Intellisense will properly show the unescaped XML sequence.
Upvotes: 6
Reputation: 16628
In XAML view, put some XAML you want to use as comment
Then surround it with
<!-- #region XAML Snippet -->
<StackPanel>
<Button Content="Click me, I do nothing!" />
</StackPanel>
<!-- #endregion -->
Note: i put this in a MainWindow.xaml file, but it can be any XAML file.
Now in C#, to use this as a comment:
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
/// <example>
/// <code source="MyProject.Namespace/MainWindow.xaml" region="XAML snippet" lang="XAML" title="A linked *.xaml file treated as XAML"/>
/// </example>
SandCastle understands this syntax, and will generate appropriate documentation (like in MSDN), however this won't show up on intellisense.
You could format a regular <summary>
body with >
and <
instead of < >
signs in order to mimic XAML syntax, but that's going to be a pain.
Upvotes: 6
Reputation: 29953
Use CDATA tags?
/// <summary>
/// <![CDATA[<StackPanel />]]>
/// </summary>
Note: this won't appear in Intellisense so if that is a requirement this method won't work for your scenario.
Why do you want to add XAML into a code file, though?
Upvotes: 2