【问题标题】:Loading AvalonEdit syntax highlighting definitions from resource从资源中加载 AvalonEdit 语法高亮定义
【发布时间】:2011-09-11 23:10:57
【问题描述】:

我有一个 AvalonEdit 文本框,我想包含语法高亮。我已经创建了我的 .xshd 文件,并将它作为资源保存在我的项目中。现在如何将它应用到我的 AvalonEdit 框?

我浏览了一堆教程,但没有一个有解决方案。

【问题讨论】:

    标签: wpf avalonedit


    【解决方案1】:

    使用这个:

    System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("MyNamespace.FileName.xshd"));
    

    【讨论】:

    • 我收到“NotSupportedException:URI 前缀无法识别。”
    【解决方案2】:

    另一种方法,对我有用:

    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);
            }
        }
    

    您需要更改WpfApp15sql

    我用过Project>... Properties>Resources>>Add Resource>Add Existing File...

    【讨论】:

      猜你喜欢
      • 2017-07-05
      • 1970-01-01
      • 1970-01-01
      • 2012-09-19
      • 2013-03-15
      • 2012-08-02
      • 1970-01-01
      • 1970-01-01
      • 2016-12-30
      相关资源
      最近更新 更多