我想在我的应用程序中包含一个XML编辑器-类似于VS的具有自动着色等功能的XML编辑器。
AvalonEdit听起来是个不错的解决方案。
但是,AvalonEdit提供了C#语法的示例,而不是XML语法。有没有XML语法的示例?
发布于 2013-03-09 21:46:28
只需在您的XAML中使用SyntaxHighlighting="XML":
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
...
<StackPanel>
<avalonedit:TextEditor SyntaxHighlighting="XML"/>
</StackPanel>发布于 2012-06-27 11:11:27
您所要做的就是更改Avalon中的xshd文件,以将其更改为所需的语言要求。Link已经在SharpDevelop Git中提供了许多公共语言语法突出显示功能
对于XML,xshd文件如下所示:
<SyntaxDefinition name="XML" extensions=".xml;.xsl;.xslt;.xsd;.manifest;.config;.addin;.xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;.booproj;.build;.xfrm;.targets;.xaml;.xpt;.xft;.map;.wsdl;.disco;.ps1xml;.nuspec" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color foreground="Green" name="Comment" exampleText="<!-- comment -->" />
<Color foreground="Blue" name="CData" exampleText="<![CDATA[data]]>" />
<Color foreground="Blue" name="DocType" exampleText="<!DOCTYPE rootElement>" />
<Color foreground="Blue" name="XmlDeclaration" exampleText='<?xml version="1.0"?>' />
<Color foreground="DarkMagenta" name="XmlTag" exampleText='<tag attribute="value" />' />
<Color foreground="Red" name="AttributeName" exampleText='<tag attribute="value" />' />
<Color foreground="Blue" name="AttributeValue" exampleText='<tag attribute="value" />' />
<Color foreground="Teal" name="Entity" exampleText="index.aspx?a=1&amp;b=2" />
<Color foreground="Olive" name="BrokenEntity" exampleText="index.aspx?a=1&b=2" />
<RuleSet>
<Span color="Comment" multiline="true">
<Begin><!--</Begin>
<End>--></End>
</Span>
<Span color="CData" multiline="true">
<Begin><!\[CDATA\[</Begin>
<End>]]></End>
</Span>
<Span color="DocType" multiline="true">
<Begin><!DOCTYPE</Begin>
<End>></End>
</Span>
<Span color="XmlDeclaration" multiline="true">
<Begin><\?</Begin>
<End>\?></End>
</Span>
<Span color="XmlTag" multiline="true">
<Begin><</Begin>
<End>></End>
<RuleSet>
<!-- Treat the position before '<' as end, as that's not a valid character
in attribute names and indicates the user forgot a closing quote. -->
<Span color="AttributeValue" multiline="true" ruleSet="EntitySet">
<Begin>"</Begin>
<End>"|(?=<)</End>
</Span>
<Span color="AttributeValue" multiline="true" ruleSet="EntitySet">
<Begin>'</Begin>
<End>'|(?=<)</End>
</Span>
<Rule color="AttributeName">[\d\w_\-\.]+(?=(\s*=))</Rule>
<Rule color="AttributeValue">=</Rule>
</RuleSet>
</Span>
<Import ruleSet="EntitySet"/>
</RuleSet>
<RuleSet name="EntitySet">
<Rule color="Entity">
&
[\w\d\#]+
;
</Rule>
<Rule color="BrokenEntity">
&
[\w\d\#]*
#missing ;
</Rule>
</RuleSet>
</SyntaxDefinition>https://stackoverflow.com/questions/11216008
复制相似问题