Table of Contents

Class SmartConverter

Namespace
SearchAThing.Desktop
Assembly
netcore-desktop.dll

Smart Converter

Parameter ( general form ):

  • ?FN targetValueIfMatch targetValueIfNOTMatch
  • valueToMatch targetValueIfMatch targetValueIfNOTMatch

Functions:

  • ?IsNull : true if given argument is null
  • ?{gt,lt,gte,ltq,eq} v : true if given argument equals to parameter v
  • ?{add,sub} v : add/sub v
  • ?Lighter : double given argument brighness
  • ?Lighter v : increase of given argument v=0-1 brighness
  • ?Darker : half brighness
  • ?Darker v : decrease to v=0-1 brightness
  • ?Round dec : round value number to given decimals

Supported target types:

  • boolean
  • double
  • Thickness
  • Brush
  • FontWeight

Examples ( converter parameter ):

  • true Yellow Transparent ( valueType: boolean, targetType:IBrush ) converts to Yellow if value is true or transparent if value if false
  • ?Darker 0.8 ( valueType: IBrush, targetType: IBrush ) converts to darker brush reducing at 80% its bridhtness
  • ?IsNull 1.2 4.5 ( valueType: object, targetType: double ) converts to 1.2 if value is null, 4.5 otherwise
  • true false true ( valueType: bool, targetType: bool ) converts to false if given value is true, viceversa otherwise
public class SmartConverter : IValueConverter
Inheritance
SmartConverter
Implements
IValueConverter
Inherited Members

Properties

Instance

public static SmartConverter Instance { get; }

Property Value

SmartConverter

Methods

Convert(object?, Type, object, CultureInfo)

Converts a value.

public object? Convert(object? value, Type targetType, object parameter, CultureInfo culture)

Parameters

value object

The value to convert.

targetType Type

The type of the target.

parameter object

A user-defined parameter.

culture 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(object, Type, object, CultureInfo)

Converts a value.

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

Parameters

value object

The value to convert.

targetType Type

The type of the target.

parameter object

A user-defined parameter.

culture 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.

operand(object?, Type, object, CultureInfo, bool)

public object? operand(object? value, Type targetType, object parameter, CultureInfo culture, bool isBackCvt)

Parameters

value object
targetType Type
parameter object
culture CultureInfo
isBackCvt bool

Returns

object