Skip to main content

ContrastBrushConverter Class

Definition

Assembly:Avalonia.Controls.ColorPicker
Package:Avalonia.Controls.ColorPicker

Gets a Avalonia.Media.SolidColorBrush, either black or white, depending on the luminance of the supplied color. A default color supplied in the converter parameter may be returned if alpha is below the set threshold.

public class ContrastBrushConverter

Inheritance: object -> ContrastBrushConverter

Implements:IValueConverter

Remarks

This is a highly-specialized converter for the color picker.

Constructors

NameDescription
ContrastBrushConverterNo summary available.

ContrastBrushConverter Constructor

public ContrastBrushConverter()

Methods

NameDescription
ConvertConverts a value.
ConvertBackConverts a value.

Convert Method

Converts a value.

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

Parameters

value object

The value to convert.

targetType Type

The type of the target.

parameter object

A user-defined parameter.

culture System.Globalization.CultureInfo

The culture to use.

Returns

object

The converted value.

Remarks

This method should not throw exceptions. If the value is not convertible, return a Avalonia.Data.BindingNotification in an error state. Any exceptions thrown will be treated as an application exception.

ConvertBack Method

Converts a value.

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

Parameters

value object

The value to convert.

targetType Type

The type of the target.

parameter object

A user-defined parameter.

culture System.Globalization.CultureInfo

The culture to use.

Returns

object

The converted value.

Remarks

This method should not throw exceptions. If the value is not convertible, return a Avalonia.Data.BindingNotification in an error state. Any exceptions thrown will be treated as an application exception.

Properties

NameDescription
AlphaThresholdGets or sets the alpha channel threshold below which a default color is used instead of black/white.

AlphaThreshold Property

Gets or sets the alpha channel threshold below which a default color is used instead of black/white.

public byte AlphaThreshold { get; set; }