I have an AvalonEdit text box, and I want to include syntax hi开发者_开发技巧ghlighting. I've already created my .xshd file, and I have it in my project as a Resource. Now how do I apply it to my AvalonEdit box?
I've looked through a bunch of tutorials, but none of them have the solution.
use this:
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("MyNamespace.FileName.xshd"));
Another way, that worked for me:
using (var stream = new MemoryStream(WpfApp15.Properties.Resources.sql))
{
using (var reader = new System.Xml.XmlTextReader(stream))
{
this.AvalonQuery.SyntaxHighlighting =
ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader,
ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance);
}
}
You need to change WpfApp15
and sql
.
I've used Project
>
... Properties
>
Resources
>
Add Resource
>
Add Existing File...
.
精彩评论