Polhem.Markdown.Avalonia 0.3.1

dotnet add package Polhem.Markdown.Avalonia --version 0.3.1
                    
NuGet\Install-Package Polhem.Markdown.Avalonia -Version 0.3.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Polhem.Markdown.Avalonia" Version="0.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Polhem.Markdown.Avalonia" Version="0.3.1" />
                    
Directory.Packages.props
<PackageReference Include="Polhem.Markdown.Avalonia" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Polhem.Markdown.Avalonia --version 0.3.1
                    
#r "nuget: Polhem.Markdown.Avalonia, 0.3.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Polhem.Markdown.Avalonia@0.3.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Polhem.Markdown.Avalonia&version=0.3.1
                    
Install as a Cake Addin
#tool nuget:?package=Polhem.Markdown.Avalonia&version=0.3.1
                    
Install as a Cake Tool

Polhem.Markdown.Avalonia

A Markdown viewer control and a Markdown source editor control for Avalonia. The viewer renders the same model as Polhem.Markdown.Blazor, so an Avalonia and a Blazor front end show the same text the same way.

The same reply in the Blazor viewer and the Avalonia viewer

MarkdownViewer

Shows Markdown: GitHub Flavored Markdown, highlighted code, math, Mermaid diagrams and the HTML that README files use. Raw HTML is never passed on, and only links and images with an allowed scheme open or load.

<Window xmlns:md="using:Polhem.Markdown.Avalonia">
  <md:MarkdownViewer Markdown="{Binding Reply}" LinkActivated="OnLinkActivated" />
</Window>
// Without a handler that marks it handled, the viewer asks the operating system to open the link.
private void OnLinkActivated(object? sender, MarkdownLinkActivatedEventArgs e)
{
    OpenInApp(e.Uri);
    e.Handled = true;
}

// Resolve relative links and images against the document's address, and allow file images.
viewer.Options = new MarkdownOptions
{
    BaseUri = new Uri("https://example.com/docs/"),
    AllowedImageSchemes = { "file" },
};

Set CjkFontFamily when the text has Chinese, Japanese or Korean, so bold CJK text keeps its weight (AvaloniaUI/Avalonia#18199):

<md:MarkdownViewer Markdown="{Binding Reply}"
                   CjkFontFamily="PingFang TC, Microsoft JhengHei UI, Noto Sans CJK TC" />

MarkdownEditor

Edits Markdown as source on AvaloniaEdit, colored the way the viewer reads it, with a toolbar, format commands and list keys. Put a MarkdownViewer beside it for a live preview:

The editor with its toolbar and line numbers, beside the viewer showing the same text

<Grid ColumnDefinitions="*,*">
  <md:MarkdownEditor x:Name="Editor" Markdown="{Binding Text}" />
  <md:MarkdownViewer Grid.Column="1" Markdown="{Binding Text}" />
</Grid>
Editor.ApplyFormat(MarkdownFormat.Bold);   // toggles bold on the selection, as Ctrl+B or Cmd+B does
Editor.CycleHeading();                     // plain text, then #, ##, ###, then plain text again

The toolbar's labels are English; give your own, or null to keep one. Set ShowToolbar="False" to lay out buttons of your own instead:

Editor.ToolbarLabels = item => item switch
{
    MarkdownToolbarItem.Bold => "粗體",
    MarkdownToolbarItem.Italic => "斜體",
    _ => null,
};

The editor brings the styles its AvaloniaEdit parts need, so it works under any theme. The gallery in the repository keeps the editor and the viewer scrolling together.

Each member's XML documentation has the details. The package is at 0.x: a minor version may still change the API. See the repository.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Polhem.Markdown.Avalonia:

Package Downloads
Polhem.Chat.Avalonia

An AI chat control for Avalonia: streamed replies rendered as Markdown, reasoning, tool calls, per-turn usage, stop and copy, on top of any Microsoft.Extensions.AI IChatClient.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.1 0 11/25/2026
0.3.0 0 11/25/2026
0.2.1 45 11/24/2026
0.2.0 48 11/24/2026
0.1.0 192 11/20/2026