Primary WinForms APIs:
RichTextBox (Text, Rtf, styled selections)LinkLabel and LinkClickedPrimary Avalonia APIs/patterns:
TextBox (AcceptsReturn, TextWrapping) for editable multiline textTextBlock inline elements (Run, Bold, Italic, Underline) for rich read-only textHyperlinkButton (NavigateUri) for link-like actions| WinForms | Avalonia |
|---|---|
RichTextBox rich editor |
TextBox for plain/multiline editing + custom formatting pipeline if needed |
RichTextBox formatted display |
TextBlock with Inlines (Run, Bold, Italic, Underline) |
LinkLabel navigation |
HyperlinkButton with NavigateUri or command |
LinkClicked event handlers |
command-first navigation/open-url services |
WinForms C#:
notesRichTextBox.Text = ticket.Notes;
statusRichTextBox.SelectionFont = new Font("Segoe UI", 9, FontStyle.Bold);
statusRichTextBox.AppendText("Ready");
docsLinkLabel.LinkClicked += (_, _) => Process.Start(ticket.HelpUrl);
Avalonia XAML:
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:MyApp.ViewModels"
x:DataType="vm:TicketViewModel">
<StackPanel Spacing="10">
<TextBox AcceptsReturn="True"
TextWrapping="Wrap"
MinHeight="120"
Text="{CompiledBinding Notes, Mode=TwoWay}" />
<TextBlock>
<Run Text="Status: " />
<Bold>Ready</Bold>
<Run Text=" - " />
<Italic>review migration notes</Italic>
<Run Text=" before deployment." />
</TextBlock>
<HyperlinkButton Content="Open Ticket Documentation"
NavigateUri="{CompiledBinding DocumentationUri}" />
</StackPanel>
</UserControl>
using System;
using Avalonia.Controls;
using Avalonia.Controls.Documents;
var notes = new TextBox
{
AcceptsReturn = true,
TextWrapping = Avalonia.Media.TextWrapping.Wrap,
Text = viewModel.Notes
};
var status = new TextBlock();
status.Inlines?.Add(new Run("Status: "));
var ready = new Bold();
ready.Inlines.Add(new Run("Ready"));
status.Inlines?.Add(ready);
status.Inlines?.Add(new Run(" - "));
var action = new Italic();
action.Inlines.Add(new Run("review migration notes"));
status.Inlines?.Add(action);
status.Inlines?.Add(new Run(" before deployment."));
var docs = new HyperlinkButton
{
Content = "Open Ticket Documentation",
NavigateUri = viewModel.DocumentationUri ?? new Uri("https://docs.avaloniaui.net/")
};
RichTextBox equivalent; keep rich editing in a dedicated domain component.HyperlinkButton with explicit theme styling and route URL launching through TopLevel.Launcher if custom behavior is needed.