HtmlToContentConverter Class

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

Namespace: DevExpress.Xpf.RichEdit

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

Declaration

[ValueConversion(typeof(string), typeof(RichEditDocumentContent))]
public class HtmlToContentConverter :
    SpecificFormatToContentConverter
<ValueConversion(GetType(String), GetType(RichEditDocumentContent))>
Public Class HtmlToContentConverter
    Inherits 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>

Inheritance

See Also