必须在 App.xaml 的 Application.Styles 中引入 avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml,否则控件无样式;用 TextMate 高亮需额外安装 AvaloniaEdit.TextMate 与 TextMateSharp.Grammars 两个包;从源码构建需带子模块克隆(git clone --recursive 或 git submodule update --init)
AvaloniaEdit
AvaloniaUIMIT活跃维护基于 Avalonia 的文本编辑器控件,从 AvalonEdit 移植而来,为跨平台 .NET 应用提供代码编辑、语法高亮等能力。
Avalonia-based text editor (port of AvalonEdit)
dotnet add package Avalonia.AvaloniaEditREADME 未说明
Avalonia 版 AvalonEdit 文本编辑器控件,给跨平台 .NET 应用直接嵌入代码编辑能力
基于 Avalonia 的文本编辑器控件,从 AvalonEdit 移植而来,为跨平台 .NET 应用提供代码编辑、语法高亮等能力。
核心能力
- 基于 TextMate 语法与主题实现语法高亮
- 支持代码折叠、代码补全与多光标编辑
- 行号显示、空白与 EOL 可视化、自动换行
- 行虚拟化与文档下方滚动,适配大文件
- 可自定义扩展,支持超链接与列内装饰
容易踩的坑
- 12.0.0最新正式版2026-10-21 · 2026-10-21 09:16 UTC
What's Changed
- 12 stable support
- Several solution modernizations by @maxkatz6 in https://github.com/AvaloniaUI/AvaloniaEdit/pull/565
- Fix crush on popup close during selection by @jl0pd in https://github.com/AvaloniaUI/AvaloniaEdit/pull/538
- Fixes multiple memory leaks and race conditions by @udlose in https://github.com/AvaloniaUI/AvaloniaEdit/pull/560
- Update ToString() to use string.Create and InvariantCulture by @udlose in https://github.com/AvaloniaUI/AvaloniaEdit/pull/572
- Mark value types as readonly for performance, immutability and safety by @udlose in https://github.com/AvaloniaUI/AvaloniaEdit/pull/573
- Replace Empty.Array with built-in Array.Empty(), add unit tests for Deque, fix CA1851 on SnippetInputHandler by @udlose in https://github.com/AvaloniaUI/AvaloniaEdit/pull/571
- Optimize DocumentSnapshot and add parameter validation by @udlose in https://github.com/AvaloniaUI/AvaloniaEdit/pull/576
- Fix for "CompletionWindow causes application crash (InvalidOperationException in GlRenderTarget) when all items are filtered out" by @DamirLisak in https://github.com/AvaloniaUI/AvaloniaEdit/pull/569
New Contributors
- @valerybokov made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/562
- @DamirLisak made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/569
Full Changelog: https://github.com/AvaloniaUI/AvaloniaEdit/compare/11.4.1...12.0.0
- 12.0.0-rc1pre-release2026-03-23 · 2026-03-23 05:35 UTC
查看更新说明
What's Changed
- Avalonia 12.0 support by @latop2604 @valerybokov @maxkatz6 in https://github.com/AvaloniaUI/AvaloniaEdit/pull/558 https://github.com/AvaloniaUI/AvaloniaEdit/pull/562 https://github.com/AvaloniaUI/AvaloniaEdit/pull/564
- Several solution modernizations by @maxkatz6 in https://github.com/AvaloniaUI/AvaloniaEdit/pull/565
- Fix crush on popup close during selection by @jl0pd in https://github.com/AvaloniaUI/AvaloniaEdit/pull/538
- Fixes multiple memory leaks and race conditions (#362) by @udlose in https://github.com/AvaloniaUI/AvaloniaEdit/pull/560
New Contributors
- @latop2604 made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/558
- @valerybokov made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/562
- @udlose made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/560
Full Changelog: https://github.com/AvaloniaUI/AvaloniaEdit/compare/11.4.1...12.0.0-rc1
- 11.4.12026-02-05 · 2026-02-05 08:28 UTC
查看更新说明
- Fix casing of
zh-Hanslocale
- Fix casing of
- 11.4.02026-02-03 · 2026-02-03 10:34 UTC
查看更新说明
This release is unchanged from 11.4.0-rc1:
What's Changed
- Update TextMateSharp nuget to 1.0.70 by @maxbrousseau in https://github.com/AvaloniaUI/AvaloniaEdit/pull/522
- Optimize heap allocations in CharRope.ToString by @YoshihiroIto in https://github.com/AvaloniaUI/AvaloniaEdit/pull/515
- Use a traditional constructor instead of a primary constructor by @danipen in https://github.com/AvaloniaUI/AvaloniaEdit/pull/504
- Implement some methods which not implemented in porting by @realybin in https://github.com/AvaloniaUI/AvaloniaEdit/pull/509
- Fix #511 by improving README.md by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/514
- Fix: TextEditor.SelectAll method doesn't work by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/513
- Adjust caret rectangle for scroll offset by @realybin in https://github.com/AvaloniaUI/AvaloniaEdit/pull/489
- fix(VisualLineElementTextRunProperties): potential crash of invalid EmSize by @realybin in https://github.com/AvaloniaUI/AvaloniaEdit/pull/506
- Fix: Update the selection when scrolling by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/500
- Fix: Insert at wrong offset in virtual space with EOL glyphs by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/499
- Add CaretBrush as DirectProperty on TextArea so it can be defined via markup by @tomlm in https://github.com/AvaloniaUI/AvaloniaEdit/pull/531
- fixed jumping / unaligned text with special characters and collapsed folding by @BobbyCannon in https://github.com/AvaloniaUI/AvaloniaEdit/pull/519
- LineNumbersMargin property added to TextEditor by @NickRimmer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/402
- Remove hardcoded line height factor by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/537
- Add TextEditorOptions.LineHeightFactor by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/539
- Add TextPasted event to TextArea by @KouniakiosKatakthths in https://github.com/AvaloniaUI/AvaloniaEdit/pull/551
- Update TextMateSharp and syntax highlight using ReadOnlyMemory for reduced allocations by @danipen in https://github.com/AvaloniaUI/AvaloniaEdit/pull/550
- Hide TextDocument._undoStack by @jl0pd in https://github.com/AvaloniaUI/AvaloniaEdit/pull/542
- Support zh-Hans for Search & Replace functions by @zdpcdt in https://github.com/AvaloniaUI/AvaloniaEdit/pull/493
- Adjust caret rectangle calculations to accomodate upcoming Avalonia versions by @danipen in https://github.com/AvaloniaUI/AvaloniaEdit/pull/546
New Contributors
- @maxbrousseau made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/522
- @YoshihiroIto made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/515
- @tomlm made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/531
- @BobbyCannon made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/519
- @NickRimmer made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/402
- @KouniakiosKatakthths made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/551
- @zdpcdt made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/493
Full Changelog: https://github.com/AvaloniaUI/AvaloniaEdit/compare/11.3.0...11.4.0-rc1
- 11.4.0-rc1pre-release2026-01-23 · 2026-01-23 08:21 UTC
查看更新说明
What's Changed
- Update TextMateSharp nuget to 1.0.70 by @maxbrousseau in https://github.com/AvaloniaUI/AvaloniaEdit/pull/522
- Optimize heap allocations in CharRope.ToString by @YoshihiroIto in https://github.com/AvaloniaUI/AvaloniaEdit/pull/515
- Use a traditional constructor instead of a primary constructor by @danipen in https://github.com/AvaloniaUI/AvaloniaEdit/pull/504
- Implement some methods which not implemented in porting by @realybin in https://github.com/AvaloniaUI/AvaloniaEdit/pull/509
- Fix #511 by improving README.md by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/514
- Fix: TextEditor.SelectAll method doesn't work by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/513
- Adjust caret rectangle for scroll offset by @realybin in https://github.com/AvaloniaUI/AvaloniaEdit/pull/489
- fix(VisualLineElementTextRunProperties): potential crash of invalid EmSize by @realybin in https://github.com/AvaloniaUI/AvaloniaEdit/pull/506
- Fix: Update the selection when scrolling by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/500
- Fix: Insert at wrong offset in virtual space with EOL glyphs by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/499
- Add CaretBrush as DirectProperty on TextArea so it can be defined via markup by @tomlm in https://github.com/AvaloniaUI/AvaloniaEdit/pull/531
- fixed jumping / unaligned text with special characters and collapsed folding by @BobbyCannon in https://github.com/AvaloniaUI/AvaloniaEdit/pull/519
- LineNumbersMargin property added to TextEditor by @NickRimmer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/402
- Remove hardcoded line height factor by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/537
- Add TextEditorOptions.LineHeightFactor by @mgarstenauer in https://github.com/AvaloniaUI/AvaloniaEdit/pull/539
- Add TextPasted event to TextArea by @KouniakiosKatakthths in https://github.com/AvaloniaUI/AvaloniaEdit/pull/551
- Update TextMateSharp and syntax highlight using ReadOnlyMemory for reduced allocations by @danipen in https://github.com/AvaloniaUI/AvaloniaEdit/pull/550
- Hide TextDocument._undoStack by @jl0pd in https://github.com/AvaloniaUI/AvaloniaEdit/pull/542
- Support zh-Hans for Search & Replace functions by @zdpcdt in https://github.com/AvaloniaUI/AvaloniaEdit/pull/493
- Adjust caret rectangle calculations to accomodate upcoming Avalonia versions by @danipen in https://github.com/AvaloniaUI/AvaloniaEdit/pull/546
New Contributors
- @maxbrousseau made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/522
- @YoshihiroIto made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/515
- @tomlm made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/531
- @BobbyCannon made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/519
- @NickRimmer made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/402
- @KouniakiosKatakthths made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/551
- @zdpcdt made their first contribution in https://github.com/AvaloniaUI/AvaloniaEdit/pull/493
Full Changelog: https://github.com/AvaloniaUI/AvaloniaEdit/compare/11.3.0...11.4.0-rc1
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
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
- Avalonia.AvaloniaEdit well-known package that incudes text editor itself.
- AvaloniaEdit.TextMate package that adds TextMate integration to the AvaloniaEdit.
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 yourApp.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));

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.