AvalonMarkdown 8.0.0
dotnet add package AvalonMarkdown --version 8.0.0
NuGet\Install-Package AvalonMarkdown -Version 8.0.0
<PackageReference Include="AvalonMarkdown" Version="8.0.0" />
<PackageVersion Include="AvalonMarkdown" Version="8.0.0" />
<PackageReference Include="AvalonMarkdown" />
paket add AvalonMarkdown --version 8.0.0
#r "nuget: AvalonMarkdown, 8.0.0"
#:package AvalonMarkdown@8.0.0
#addin nuget:?package=AvalonMarkdown&version=8.0.0
#tool nuget:?package=AvalonMarkdown&version=8.0.0
AvalonMarkdown
A Markdown preview control built on AvaloniaUI's NativeWebView β renders Markdown with math (KaTeX), code highlighting (highlight.js), diagrams (Mermaid / PlantUML), and video embeds.
π δΈζζζ‘£
Installation
dotnet add package AvalonMarkdown
MarkdownView
A drop-in Markdown preview control.
<Window xmlns="https://github.com/avaloniaui"
xmlns:md="clr-namespace:AvalonMarkdown.Views;assembly=AvalonMarkdown">
<md:MarkdownView x:Name="Preview" />
</Window>
Rendering content
Recommended β bind the Text property (updates are deduplicated automatically):
<md:MarkdownView Text="{Binding MarkdownContent}" />
Or render explicitly once the control is ready:
Preview.OnReady += async (_, _) =>
{
await Preview.RenderMarkdownAsync("# Hello World\n\n**Bold** *Italic*");
};
Link navigation
Every hyperlink click is raised as LinkClicked. Set Handled = true to take over navigation (e.g. in-app routing); otherwise the link opens in the system browser by default.
Preview.LinkClicked += (_, e) =>
{
if (e.Url.StartsWith("app://"))
{
NavigateInternal(e.Url);
e.Handled = true; // suppress the default system-browser launch
}
};
Preview configuration
Content updates auto-scroll to the newest content, pausing while you operate the scrollbar. Tune via ApplyConfigAsync:
await Preview.ApplyConfigAsync("setPreviewConfig({ autoScrollOnUpdate: true, autoScrollCooldown: 2000 })");
Key API
| Member | Type | Description |
|---|---|---|
Text |
string? |
Markdown content (two-way bindable) |
Placeholder |
string? |
Text shown when content is empty (default blank) |
OnReady |
event |
Fires when the preview is ready to render |
LinkClicked |
event |
Fires on every hyperlink click; Handled = true intercepts navigation |
ErrorOccurred |
event |
Fires on internal recoverable errors |
RenderMarkdownAsync(text) |
Task |
Renders Markdown content |
RestartPreviewAsync() |
Task |
Restarts the preview |
ApplyConfigAsync(js) |
Task |
Applies preview configuration |
ApplyCustomCssAsync(css) |
Task |
Injects custom CSS overrides |
InvokeScriptAsync(js) |
Task<string?> |
Executes custom JavaScript |
ScrollToProgressAsync(percent) |
Task |
Scrolls the preview to a vertical progress position (0β100) |
GetScrollProgressAsync() |
Task<double?> |
Returns the current vertical scroll progress (0β100) |
NavigateToHeadingAsync(heading) |
Task<bool> |
Scrolls to the matching heading (for TOC); returns whether found |
GetHeadingsAsync() |
Task<IReadOnlyList<MarkdownHeading>> |
Lists all headings (text + level) to build a table of contents |
MarkdownThemeView
A built-in theme editor that targets a MarkdownView. RGB sliders for colors, plus controls for typography, code highlighting, and Mermaid/PlantUML styles β changes auto-apply.
<md:MarkdownView x:Name="Preview" />
<md:MarkdownThemeView Target="{Binding #Preview}" />
Collapsed by default; click the title bar to expand.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Avalonia (>= 12.0.0)
- Avalonia.Controls.WebView (>= 12.0.0)
- Avalonia.Fonts.Inter (>= 12.0.0)
- Avalonia.Themes.Fluent (>= 12.0.0)
-
net8.0
- Avalonia (>= 12.0.0)
- Avalonia.Controls.WebView (>= 12.0.0)
- Avalonia.Fonts.Inter (>= 12.0.0)
- Avalonia.Themes.Fluent (>= 12.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.