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.v19.2.dll

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.

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E3490.

<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>

The following code snippets (auto-collected from DevExpress Examples) contain references to the HtmlToContentConverter class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

See Also