Back to Devexpress

ContentToHtmlConverter Class

wpf-devexpress-dot-xpf-dot-richedit-a7744d9f.md

latest4.3 KB
Original Source

ContentToHtmlConverter Class

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

Namespace : DevExpress.Xpf.RichEdit

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

NuGet Package : DevExpress.Wpf.RichEdit

Declaration

csharp
[ValueConversion(typeof(RichEditDocumentContent), typeof(string))]
public class ContentToHtmlConverter :
    ContentToSpecificFormatConverter
vb
<ValueConversion(GetType(RichEditDocumentContent), GetType(String))>
Public Class ContentToHtmlConverter
    Inherits 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.

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

Object ContentToSpecificFormatConverter ContentToHtmlConverter

See Also

ContentToHtmlConverter Members

DevExpress.Xpf.RichEdit Namespace