TX Text Control .NET for WPF

ColorConverter Class

Class|Introduced in 16.0
Namespace
TXTextControl.WPF
Package
TXTextControl.TextControl.WPF.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXTextControl.WPF.dll
Install
dotnet add package TXTextControl.TextControl.WPF.SDK .NET 8 and later. For .NET Framework, reference TXTextControl.WPF.dll from the setup.
Implements
IValueConverter

Description

The WPF.ColorConverter class provides a way to convert a System.Drawing.Color value to System.Windows.Media.Color value. With this converter a property with a System.Drawing.Color type can be used in a XAML data binding.

Syntax

public class ColorConverter : IValueConverter

Examples

The following XAML example shows how to bind the InputFormat.TextColor property to the fill color of a rectangle using the ColorConverter class.

…
xmlns:tx="clr-namespace:TXTextControl.WPF;assembly=TXTextControl.WPF"
…
<Window.Resources>
    <tx:ColorConverter x:Key="colorConv" />
</Window.Resources>
…
<Rectangle
    Width="20"
    Height="20">
    <Rectangle.Fill>
        <SolidColorBrush
            Color="{Binding
                ElementName=textControl1,
                Path=InputFormat.TextColor,
                Converter={StaticResource colorConv}}" />
    </Rectangle.Fill>
</Rectangle>

The following example creates a Color Converter instance for a document-processing operation. The created object is then available to the surrounding document workflow.

TXTextControl.WPF.ColorConverter colorConverter = new();
Console.WriteLine("Color Converter is ready for use.");

Members

Constructors

ConstructorDescription
ColorConverterNot described in the reference. public ColorConverter();

Methods

MethodDescription
ConvertConverts a System.Drawing.Color value to System.Windows.Media.Color value.
ConvertBackConverts a System.Windows.Media.Color to a System.Drawing.Color value.