Skip to main content
A newer version of this page is available. .

HtmlToContentConverter Class

An HTML-to-Content format converter associated with a binding.

Namespace: DevExpress.Xpf.RichEdit

Assembly: DevExpress.Xpf.RichEdit.v20.2.dll

NuGet Packages: DevExpress.WindowsDesktop.Wpf.RichEdit, DevExpress.Wpf.RichEdit

Declaration

[ValueConversion(typeof(string), typeof(RichEditDocumentContent))]
public class HtmlToContentConverter :
    SpecificFormatToContentConverter

Remarks

Implements the IValueConverter interface and allows conversion from HTML format to the control’s content.

See the ContentToPlainTextConverter topic for more information.

<Window x:Class="RichEditBindingConvertersWpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
        xmlns:dxre="http://schemas.devexpress.com/winfx/2008/xaml/richedit"
        Title="MainWindow"
        Height="600" Width="800" WindowState="Maximized">

    <Window.Resources>
        <dxre:ContentToHtmlConverter x:Key="contentToHtmlConverter"/>
        <dxre:HtmlToContentConverter x:Key="htmlToContentConverter"/>
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <Label Content="Binding Source" />
        <Label Grid.Column="1" Content="Binding Target" />

        <TextBlock Grid.Row="1" Grid.ColumnSpan="2"
                                Text="ContentToSpecificFormatConverter:"/>

        <dxre:RichEditControl x:Name="reBindingSource"
                              Grid.Row="2"
                              ActiveViewType="Simple"
                              Loaded="reBindingSource_Loaded"/>
        <TextBox x:Name="tbBindingTarget"
                  Grid.Column="1"
                  Grid.Row="2"
                  Text="{Binding ElementName=reBindingSource,
                                 Path=Content,
                                 Converter={StaticResource contentToHtmlConverter},
                                 UpdateSourceTrigger=PropertyChanged,
                                 Mode=OneWay}"/>

        <TextBlock Grid.Row="3"
         Grid.ColumnSpan="2"
         Text="SpecificFormatToContentConverter:"/>

        <TextBox x:Name="tbBindingSource"
         Grid.Row="4"
          Loaded="tbBindingSource_Loaded" />
        <dxre:RichEditControl x:Name="reBindingTarget"
                              Grid.Column="1"
                              Grid.Row="4"
                              ActiveViewType="Simple"
                              Content="{Binding ElementName=tbBindingSource,
                                                Path=Text,
                                                Converter={StaticResource htmlToContentConverter},
                                                UpdateSourceTrigger=PropertyChanged,
                                                Mode=OneWay}"/>
    </Grid>
</Window>

Inheritance

See Also