Sample projects on GitHub
Every feature in this documentation has a runnable project behind it. They live in a public repository: github.com/spicelogic/wpf-html-editor-control-samples, and they are the same projects that ship inside the trial download. Each one is a small WPF application referencing the shipping NuGet package, so there is nothing to wire up and no license key to obtain first - every sample runs on the free trial exactly as it is checked in.
The sample code is MIT licensed, so you can copy any of it straight into your own application. The control itself remains commercial and is installed from NuGet.
What is in the repository
Ten samples, most of them shipping a C# project and a VB.NET twin side by side in a matching -VB folder, both wired into the same solution.
- 01-Quickstart - the editor filling a window in XAML, starting content through
BodyHtml, and a status bar driven byHtmlChanged. - 02-MvvmDataBinding - the one most people come for.
BodyHtmlbound two-way to a view model, and why you callUpdateBindingsbefore reading a bound value. - 03-ThemeAndAppearance - border colour and thickness, the document font, and switching
EditorModebetween the design view and the source view. - 04-ToolbarCustomization - hiding built-in buttons, moving editor commands into a toolbar of your own, and adding buttons that act on the document.
- 05-MailMergeTemplate - registering merge fields, the built-in placeholder toolbar, and previewing a template with a record substituted in.
- 06-Localization - switching the editor UI language at runtime, an independent spell-check dictionary language, and a JSON file for overriding individual strings.
- 07-CustomSpellChecker - plugging your own spell-check engine in behind the editor's inline checking.
- 08-CustomDialog - replacing every built-in dialog (image, hyperlink, table, symbol, search, spell check, style builder, colour picker) with your own WPF windows, so the editor carries your branding.
- 09-CustomContextMenu - replacing the right-click menu with your own commands.
- 10-FullEditorDemo - the wider tour: the full toolbar, rich starting content, and live spell checking with a language picker.
The gotcha the binding sample is built around
The editor hosts a live document rather than a plain string, so a bound view model property reflects whatever the binding last pushed into it. If you read that property from code which runs without the editor losing focus first - a keyboard shortcut, a background timer, a button that does not move focus - the view model is a moment behind the user's last keystrokes. Call UpdateBindings before reading, and the current content is pushed into the dependency properties first. This is the single most common support question about the control, which is why sample 02 is built entirely around it.
Which .NET version you need
Whichever one your application already uses. The control ships binaries for .NET Framework 4.5, 4.7.2 and 4.8, and for .NET 5, 6, 7, 8, 9 and 10 on Windows, so a long-lived WPF application on .NET Framework 4.8 is a first-class target rather than a compatibility afterthought.
The samples are checked in targeting net8.0-windows as a default. The target framework lives in a single line of Directory.Build.props at the repository root, which every project inherits, so retargeting the whole set is one edit:
<TargetFramework>net48</TargetFramework>
Every sample is verified building on net45, net472, net48, net8.0-windows and net10.0-windows, with no source edits needed after retargeting.
Running the samples
You need Windows and the SDK matching whichever target you build against.
git clone https://github.com/spicelogic/wpf-html-editor-control-samples.git
cd wpf-html-editor-control-samples
dotnet build WpfHtmlEditorSamples.sln
dotnet run --project 01-Quickstart
You can also open WpfHtmlEditorSamples.sln in Visual Studio and set any project as the startup project.
Building on Windows Forms as well
The WinForms edition has its own sample repository covering Word paste cleanup, data binding, custom dialogs and mail merge: github.com/spicelogic/winforms-html-editor-control-samples. See the WinForms HTML Editor control for the product itself.