Setting editor border

    The WPF HTML Editor draws a plain default border around its editing surface, but your application may need that border to say more: a red outline when a field fails validation, a highlighted border while the control has focus, or just a color and thickness that matches the rest of your form instead of the editor's stock look. The WpfHtmlEditor exposes two dependency properties that control the border drawn around the editing surface:

    • EditorBorderColor - type System.Windows.Media.Color. The color of the border around the editing surface.
    • EditorBorderWidth - type System.Windows.Thickness. The per-side width of the border, exactly like a WPF Margin.

    A common use is to change the color and width conditionally, for example to make an entry stand out visually when it is flagged as critical.

    Service-bay WPF application showing the HTML Editor with a 4-pixel red EditorBorder around the editing surface, signalling a critical-fault entry to the technician.
    Service-bay WPF application showing the HTML Editor with a 4-pixel red EditorBorder around the editing surface, signalling a critical-fault entry to the technician.

    Set EditorBorderColor="Red" and EditorBorderWidth="4" as XAML literals for a fixed border, or bind both properties to view-model state to change it dynamically:

    <wpf:WpfHtmlEditor x:Name="editor"                     EditorBorderColor="{Binding EntryBorderColor}"                     EditorBorderWidth="{Binding EntryBorderThickness}" />

    The bound properties compute their value from a boolean flag:

    public Color EntryBorderColor => IsCriticalFault ? Color.FromRgb(0xCC, 0x00, 0x00) // bay-warning red : Color.FromRgb(0xCC, 0xCC, 0xCC); // neutral grey    public Thickness EntryBorderThickness => IsCriticalFault ? new Thickness(4) // shout : new Thickness(1); // quiet
    Return _

    When the flag changes, PropertyChanged fires and the editor redraws automatically, no code-behind needed.

    To hide the border, for example inside an already-bordered container, set the width to a zero Thickness:

    <wpf:WpfHtmlEditor x:Name="summaryEditor" EditorBorderWidth="0" />

    From code-behind that's:

    summaryEditor.EditorBorderWidth = new Thickness(0);
    summaryEditor.EditorBorderWidth = New Thickness(0)

    Both properties can also be set directly from code-behind, for example to highlight an editor after a diagnostic check fails:

    using System.Windows; using System.Windows.Media;  private void OnDiagnosticFailed() {     editor.EditorBorderColor = Color.FromRgb(0xCC, 0x00, 0x00);     editor.EditorBorderWidth = new Thickness(4); }
    Imports System.Windows Imports System.Windows.Media  End Sub  Private Sub OnDiagnosticFailed()     editor.EditorBorderColor = Color.FromRgb(&HCC, &H00, &H00)     editor.EditorBorderWidth = New Thickness(4)
    WPF HTML Editor with EditorBorderWidth set to Thickness(0), embedded as a borderless summary view inside an already-bordered card so the host owns the chrome.
    WPF HTML Editor with EditorBorderWidth set to Thickness(0), embedded as a borderless summary view inside an already-bordered card so the host owns the chrome.

    Last updated on May 15, 2026

    Put this into practice.

    WPF HTML Editor Control ships with free C# and VB.NET sample projects and a 14-day evaluation.

    Prefer a guided look? Book a free live demo with our engineers - live on Zoom or Teams, never a chatbot.