AvaloniaEdit

AvaloniaUIMIT活跃维护

基于 Avalonia 的文本编辑器控件,从 AvalonEdit 移植而来,为跨平台 .NET 应用提供代码编辑、语法高亮等能力。

Avalonia-based text editor (port of AvalonEdit)

12.0.0发布于 2026-10-21 09:16 UTC1,148star242fork同步于 2026-11-10 17:52 UTC

怎么上手

由 README 提炼,执行前请确认
dotnet add package Avalonia.AvaloniaEdit
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Avalonia 版 AvalonEdit 文本编辑器控件,给跨平台 .NET 应用直接嵌入代码编辑能力

基于 Avalonia 的文本编辑器控件,从 AvalonEdit 移植而来,为跨平台 .NET 应用提供代码编辑、语法高亮等能力。

核心能力

  • 基于 TextMate 语法与主题实现语法高亮
  • 支持代码折叠、代码补全与多光标编辑
  • 行号显示、空白与 EOL 可视化、自动换行
  • 行虚拟化与文档下方滚动,适配大文件
  • 可自定义扩展,支持超链接与列内装饰

容易踩的坑

必须在 App.xaml 的 Application.Styles 中引入 avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml,否则控件无样式;用 TextMate 高亮需额外安装 AvaloniaEdit.TextMate 与 TextMateSharp.Grammars 两个包;从源码构建需带子模块克隆(git clone --recursive 或 git submodule update --init)

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本12.0.0
  1. 12.0.0最新正式版2026-10-21 · 2026-10-21 09:16 UTC

    What's Changed

    New Contributors

    Full Changelog: https://github.com/AvaloniaUI/AvaloniaEdit/compare/11.4.1...12.0.0

  2. 12.0.0-rc1pre-release2026-03-23 · 2026-03-23 05:35 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/AvaloniaUI/AvaloniaEdit/compare/11.4.1...12.0.0-rc1

  3. 11.4.12026-02-05 · 2026-02-05 08:28 UTC
    查看更新说明
    • Fix casing of zh-Hans locale
  4. 11.4.02026-02-03 · 2026-02-03 10:34 UTC
    查看更新说明

    This release is unchanged from 11.4.0-rc1:

    What's Changed

    New Contributors

    Full Changelog: https://github.com/AvaloniaUI/AvaloniaEdit/compare/11.3.0...11.4.0-rc1

  5. 11.4.0-rc1pre-release2026-01-23 · 2026-01-23 08:21 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/AvaloniaUI/AvaloniaEdit/compare/11.3.0...11.4.0-rc1

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    downloads Current stable version

    AvaloniaEdit

    This project is a port of AvalonEdit, a WPF-based text editor for Avalonia.

    AvaloniaEdit supports features like:

    • Syntax highlighting using TextMate grammars and themes.
    • Code folding.
    • Code completion.
    • Fully customizable and extensible.
    • Line numeration.
    • Display whitespaces EOLs and tabs.
    • Line virtualization.
    • Multi-caret edition.
    • Intra-column adornments.
    • Word wrapping.
    • Scrolling below document.
    • Hyperlinks.

    and many,many more!

    AvaloniaEdit currently consists of 2 packages

    Getting started

    How to set up a new project that displays an AvaloniaEdit editor?

    • Create an empty Avalonia application.
    • Add a the nuget reference to the latest version: <PackageReference Include="Avalonia.AvaloniaEdit" Version="x.y.z.t" />
    • Include the needed styles into your <Application.Styles> in your App.xaml:
      <Application xmlns="https://github.com/avaloniaui"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   x:Class="MyAvaloniaApplication.App"
                   RequestedThemeVariant="Default">
        <Application.Styles>
          <FluentTheme />
      
          <!-- AvaloniaEdit styles (required!) -->
          <StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
      
        </Application.Styles>
      </Application>
      
    • Finally, add the AvaloniaEdit editor into your window:
      <Window xmlns="https://github.com/avaloniaui"
              ...
              xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
              ...>
        ...
        <AvaloniaEdit:TextEditor Text="Hello AvaloniaEdit!"
                                 ShowLineNumbers="True"
                                 FontFamily="Cascadia Code,Consolas,Menlo,Monospace"/>
        ...
      </Window>
      

    You can see the Demo Application as a reference.

    How to set up TextMate theme and syntax highlighting for my project?

    First of all, if you want to use grammars supported by TextMateSharp, should install the following packages:

    Alternatively, if you want to support your own grammars, you just need to install the AvaloniaEdit.TextMate package, and implement IRegistryOptions interface, that's currently the easiest way in case you want to use AvaloniaEdit with the set of grammars different from in-bundled TextMateSharp.Grammars.

    //First of all you need to have a reference for your TextEditor for it to be used inside AvaloniaEdit.TextMate project.
    var _textEditor = this.FindControl<TextEditor>("Editor");
    
    //Here we initialize RegistryOptions with the theme we want to use.
    var  _registryOptions = new RegistryOptions(ThemeName.DarkPlus);
    
    //Initial setup of TextMate.
    var _textMateInstallation = _textEditor.InstallTextMate(_registryOptions);
    
    //Here we are getting the language by the extension and right after that we are initializing grammar with this language.
    //And that's all 😀, you are ready to use AvaloniaEdit with syntax highlighting!
    _textMateInstallation.SetGrammar(_registryOptions.GetScopeByLanguageId(_registryOptions.GetLanguageByExtension(".cs").Id));
    

    avaloniaedit-demo

    Building

    Clone with submodules (git clone --recursive, or git submodule update --init after cloning), then use dotnet build / dotnet test as usual.

    Packaging is driven by a NUKE build in build/:

    # Run tests, build and pack every library into artifacts/packages, then install
    # them into the local NuGet cache as 9999.0.0-localbuild for testing in other apps
    dotnet run --project build/_build.csproj
    
    # Only create the packages (and their SBOMs)
    dotnet run --project build/_build.csproj -- --target CreateNugetPackages
    

    Translations

    Czech, French, German, Italian, Japanese, Korean, Polish, Portuguese (Brazil), Russian, Spanish, Turkish and Chinese (Traditional) are adapted from the Visual Studio Code localization (MIT, Microsoft). Swedish by Svante Seleborg.