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

[ValueConversion(typeof(System.Drawing.Color), typeof(System.Windows.Media.Color))]
public class ColorConverter : IValueConverter
Public Class ColorConverter
  Implements IValueConverter

Introduced: 16.0.

Examples

Enter an introductory text for your TXTextControl.WPF.ColorConverter Class example here, or leave blank, if there is nothing to say.

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

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.