New to Telerik UI for .NET MAUIStart a free 30-day trial

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:

C#
public class KeyValueConverter : IValueConverter

Inheritance: objectKeyValueConverter

Implements: IValueConverter

Constructors

Initializes a new instance of the KeyValueConverter class.

C#
public KeyValueConverter()

Properties

Items

ResourceDictionary

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

C#
public ResourceDictionary Items { get; }
Property Value:

A ResourceDictionary containing the key-value pairs for mapping.

Methods

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

C#
public object Convert(object value, Type type, object parameter, CultureInfo culture)
Parameters:valueobject

The value to convert.

typeType

The type of the binding target property.

parameterobject

The converter parameter to use.

cultureCultureInfo

The culture to use in the converter.

Returns:

object

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

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

C#
public object ConvertBack(object value, Type type, object parameter, CultureInfo culture)
Parameters:valueobject

The key to convert back to a value.

typeType

The type to convert to.

parameterobject

The converter parameter to use.

cultureCultureInfo

The culture to use in the converter.

Returns:

object

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