Using code tag to link to a XAML snippet

Mar 27, 2008 at 12:37 AM
Is it possible to use the code tag to pull a portion of a XAML file?

/// <example>
/// <code source="foo.xaml" region="foo" title="My Title" lang="xaml" />
/// </example>

I don't know how I to define the region inside the XAML file. Standard region tags don't work (I still want the XAML to be vaild). I tried putting the region tags inside XML comments like this:

<!-- #region foo ->
<Page x:Name="foo" />
<!-- #endregion -->

and it almost worked. The XAML in between the two comments was rendered in the final output BUT it was followed by the <!-- on line #3 of my example above, like so:

My Title
<Page x:Name="foo" />

Is there a way to do this?

Thanks, David
Mar 27, 2008 at 2:55 AM
Edited Mar 27, 2008 at 2:56 AM
I'll have to modify it to handle the XML style comments in a similar fashion to how it handles VB.NET regions within a method body (basically it just trims off the trailing characters if it sees them there). Currently, it also won't highlight the XAML as it won't recognize "XAML" as a language. You can add it to the mappings in the .\Colorizer\highlight.xml file under the main SHFB installation folder and have it map to the XML rules. If you can send me a few samples so I've got more to test with, I'll get it in the next release. My e-mail address is in the About box and the footer of the pages in the help file.

Apr 5, 2008 at 1:44 AM
I've fixed the issue for the next release. It should now handle any file type that doesn't natively support #region/#endregion by using comments to put them in the code. I've set the colorizer to use the XML rules if it see "XAML" as the language. I found some XAML examples and it seems to colorize them okay using the XML rule set since it is a form of XML.