Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

ContentToHtmlConverter Class

A Content-to-HTML converter associated with a binding.

Namespace: DevExpress.Xpf.RichEdit

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

NuGet Package: DevExpress.Wpf.RichEdit

#Declaration

[ValueConversion(typeof(RichEditDocumentContent), typeof(string))]
public class ContentToHtmlConverter :
    ContentToSpecificFormatConverter

#Remarks

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

Uses the RichEditControl.HtmlText property to obtain content in HTML format.

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