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:
public class KeyValueConverter : IValueConverter
Inheritance: objectKeyValueConverter
Implements:
Constructors
Initializes a new instance of the KeyValueConverter class.
public KeyValueConverter()
Properties
Items
ResourceDictionary
Gets the collection of key-value pairs used for conversion.
public ResourceDictionary Items { get; }
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.
public object Convert(object value, Type type, object parameter, CultureInfo culture)
The value to convert.
typeTypeThe type of the binding target property.
parameterobjectThe converter parameter to use.
cultureCultureInfoThe culture to use in the converter.
Returns: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.
public object ConvertBack(object value, Type type, object parameter, CultureInfo culture)
The key to convert back to a value.
typeTypeThe type to convert to.
parameterobjectThe converter parameter to use.
cultureCultureInfoThe culture to use in the converter.
Returns:The value associated with the specified key, or null if no matching key is found.