开发者

Loading AvalonEdit syntax highlighting definitions from resource

开发者 https://www.devze.com 2023-03-12 07:21 出处:网络
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 Ava

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....

0

精彩评论

暂无评论...
验证码 换一张
取 消