Using the HTML editor in WPF application

This control is not only good for Windows Form Applications, but also usable in WPF Applications.

First, we recommend to check our dedicated WPF Html Editor control for using in WPF Application.

But, if you still want to use the WinForm version in WPF, you can do that too. In order to use this editor in WPF, you can use WindowsFormsHost element within WPF. We have already provided a sample WPF application in the Sample projects folder that you can easily find from the downloaded package.

Anyway, here is a sample XAML code.

        Title="MainWindow" Height="600" Width="715.164" Loaded="Window_Loaded">
        <winForm:WinFormHtmlEditor x:Key="formHTMLEditor" BodyHtml="Hello World" HtmlChanged="WinFormHtmlEditor_HtmlChanged">
                <userOptions:SpellCheckerOption FireInlineSpellCheckingOnKeyStroke="True"/>
                <userOptions:UserOption EnterKeyResponse="LineBreak" />
    <StackPanel Orientation="Vertical">
        <Label Margin="20 0" Content="Win Form HTML Editor within WPF Dock Panel" HorizontalAlignment="Left" VerticalAlignment="Top"/>
        <DockPanel Margin="20" Background="#9FBAAE" Visibility="Visible" HorizontalAlignment="Stretch">
            <WindowsFormsHost Height="400" Child="{StaticResource formHTMLEditor}" />
        <Label Margin="10" x:Name="lblStatus" Content="Status" HorizontalAlignment="Left" VerticalAlignment="Top"/>
        <Button Margin="10" Padding="4" Content="Set BodyHtml" HorizontalAlignment="Left" VerticalAlignment="Top" Width="85" Click="btnBodyHtmlSetter_Click"/>

In the Windows Loaded event, you should call the focus method for combo boxes in order to get rid of the pre selections in combo boxes.

        private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)


Once you use the provided XAML, the designer will show the editor as follows:

WPF- XAML- Design- View

and when you run the application, it will look like this:


Last updated on 22 November 2017, Wednesday, 10:06:29 AM
If you have any questions or concerns about this tutorial, Please feel free to share your comment.