ColorConverter Class
- Namespace
TXTextControl.WPF
- Package
TXTextControl.from the private NuGet feed or Text Control Offline PackagesTextControl. WPF. SDK
- Assembly
TXTextControl.WPF. dll
- Install
dotnet add package TXTextControl..NET 8 and later. For .NET Framework, referenceTextControl. WPF. SDK TXTextControl.from the setup.WPF. dll
- Implements
- IValue
Converter
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 : IValueConverterPublic Class ColorConverter
Implements IValueConverterExamples
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.");Dim colorConverter As New TXTextControl.WPF.ColorConverter()
Console.WriteLine("Color Converter is ready for use.")Members
Constructors
| Constructor | Description |
|---|---|
| ColorConverter | Not described in the reference. public ColorConverter(); |
Methods
| Method | Description |
|---|---|
| Convert | Converts a System.Drawing.Color value to System.Windows.Media.Color value. |
| ConvertBack | Converts a System.Windows.Media.Color to a System.Drawing.Color value. |