Skip to main content

AccentColorConverter Class

Definition​

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

Creates an accent color for a given base color value and step parameter.

public class AccentColorConverter

Inheritance: object -> AccentColorConverter

Implements:IValueConverter

Remarks​

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

Constructors​

NameDescription
AccentColorConverterNo summary available.

AccentColorConverter Constructor​

public AccentColorConverter()

Methods​

NameDescription
ConvertConverts a value.
ConvertBackConverts a value.
GetAccentThis does not account for perceptual differences and also does not match with system accent color calculation.

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.

GetAccent Method​

This does not account for perceptual differences and also does not match with system accent color calculation.

public Avalonia.Media.HsvColor GetAccent(Avalonia.Media.HsvColor hsvColor, int accentStep)

Parameters​

hsvColor Avalonia.Media.HsvColor

The base color to calculate the accent from.

accentStep int

The number of accent color steps to move.

Returns​

Avalonia.Media.HsvColor

The new accent color.

Remarks​

Use the HSV representation as it's more perceptual. In most cases only the value is changed by a fixed percentage so the algorithm is reproducible.

Fields​

NameDescription
ValueDeltaThe amount to change the Value component for each accent color step.

ValueDelta Field​

The amount to change the Value component for each accent color step.

public double ValueDelta