A cross-platform .NET MAUI control that renders Rich Text Format (RTF) content. It maps onto each platform's native text rendering, so RTF looks the way the platform intends:
| Platform | Backing view | RTF rendering |
|---|---|---|
| iOS / Mac Catalyst | UITextView |
Native NSAttributedString RTF parser |
| Windows | RichEditBox (read-only) |
Native Document.SetText(FormatRtf, …) |
| Android | TextView |
Built-in RTF → Spanned parser (no native RTF support) |
dotnet add package Plugin.RTFViewTargets net10.0-android, net10.0-ios, net10.0-maccatalyst, and net10.0-windows10.0.19041.0.
Register the handler in MauiProgram.cs:
using Plugin.RTFView;
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseRtfView(); // 👈 registers the RtfView handler
return builder.Build();
}<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:rtf="clr-namespace:Plugin.RTFView;assembly=Plugin.RTFView"
x:Class="MyApp.MainPage">
<rtf:RtfView RtfSource="{Binding Document}" />
</ContentPage>using Plugin.RTFView;
var view = new RtfView
{
RtfSource = @"{\rtf1\ansi {\colortbl;\red200\green0\blue0;}" +
@"\b\fs28\cf1 Hello\b0 \i world\i0 !\par}"
};| Member | Type | Description |
|---|---|---|
RtfView |
View |
The control. |
RtfView.RtfSource |
string? |
The raw RTF markup to render. Bindable (RtfSourceProperty). |
RtfViewBuilderExtensions.UseRtfView() |
extension | Registers the handler on the MauiAppBuilder. |
Setting RtfSource to null or an empty string clears the view. Malformed RTF is handled gracefully — the control logs a diagnostic and clears rather than throwing.
The native platforms (iOS/Mac/Windows) support the full breadth of their respective RTF engines. The Android parser is a pragmatic, dependency-free subset covering the common cases:
- Groups
{ }with inherited state - Bold, italic, and underline (
\b \i \ul+ their0/noneforms,\plain) - Foreground colour (
\colortbl+\cf) - Background / highlight colour (
\cb,\highlight) - Font family (
\fonttbl+\f) - Font size (
\fs, half-points → density-independent pixels) - Paragraph alignment (
\ql \qc \qr \qj,\pard) - Paragraph and line breaks (
\par,\line), tabs (\tab) - Escaped characters (
\\ \{ \}),\'xxhex bytes, and\uNUnicode with\ucNfallback skipping
These do not map cleanly onto a TextView / Spanned model and degrade to plain (unstyled / unaligned) text:
- Lists, tables
- Embedded images / objects (
\pict,\object) - Indents, line spacing, tab stops
- Superscript / subscript
dotnet build # all platforms
dotnet build -f net10.0-android # a single target
dotnet pack -c Release # produce the NuGet package (all four platforms)The net10.0-windows target builds on macOS/Linux as well, via <EnableWindowsTargeting>true</EnableWindowsTargeting> (it compiles against the Windows reference assemblies).
Note: cross-compiled Windows binaries are not runtime-tested by the build. The Windows rendering path should still be smoke-tested on an actual Windows host before release.
DILLIGAF License v1.0 © 2026 Paul F. Johnson.