Class
KeyValueConverter

Represents a value converter that maps values using key-value pairs stored in a ResourceDictionary. This converter allows bidirectional mapping between keys and values for data binding scenarios.

Definition

Namespace:Telerik.Maui.Controls

Assembly:Telerik.Maui.Controls.dll

Syntax:

cs-api-definition
public class KeyValueConverter : IValueConverter

Inheritance: objectKeyValueConverter

Implements: IValueConverter

Constructors

KeyValueConverter()

Initializes a new instance of the KeyValueConverter class.

Declaration

cs-api-definition
public KeyValueConverter()

Properties

Items

Gets the collection of key-value pairs used for conversion.

Declaration

cs-api-definition
public ResourceDictionary Items { get; }

Property Value

ResourceDictionary

A ResourceDictionary containing the key-value pairs for mapping.

Methods

Convert(object, Type, object, CultureInfo)

Converts a value to its corresponding key by searching for the value in the Items collection.

Declaration

cs-api-definition
public object Convert(object value, Type type, object parameter, CultureInfo culture)

Parameters

value

object

The value to convert.

type

Type

The type of the binding target property.

parameter

object

The converter parameter to use.

culture

CultureInfo

The culture to use in the converter.

Returns

object

The key associated with the specified value, or null if no matching value is found.

ConvertBack(object, Type, object, CultureInfo)

Converts a key back to its corresponding value by searching for the key in the Items collection.

Declaration

cs-api-definition
public object ConvertBack(object value, Type type, object parameter, CultureInfo culture)

Parameters

value

object

The key to convert back to a value.

type

Type

The type to convert to.

parameter

object

The converter parameter to use.

culture

CultureInfo

The culture to use in the converter.

Returns

object

The value associated with the specified key, or null if no matching key is found.