DictionaryValueAccessConverter<T> 类
- 程序集
- ClassIsland.Core.dll
用于在绑定中通过string类型的键访问以string为键,以T类型为值的字典的值的多项值转换器。
使用时需要以此抽象类为基类新建一个类,并将字典值的类型作为继承时的类型参数。(为什么不直接在XAML中传入泛型参数)
在转换时,第一个传入的绑定指向要访问的字典,第二个值指向要访问的键。如果获取值失败将返回 null。
此转换器不能反向转换。
public abstract class DictionaryValueAccessConverter<T> : IMultiValueConverter
类型参数
T字典值类型
- 继承
-
DictionaryValueAccessConverter<T>
- 实现
-
IMultiValueConverter
- Derived
- 继承成员
方法
Convert(IList<object?>, Type, object, CultureInfo)
Converts multi-binding inputs to a final value.
public object? Convert(IList<object?> values, Type targetType, object parameter, CultureInfo culture)
参数
valuesIList<object>The values to convert.
targetTypeTypeThe type of the target.
parameterobjectA user-defined parameter.
cultureCultureInfoThe culture to use.
返回
- object
The converted value.
备注
This method should not throw exceptions. If the value is not convertible, return Avalonia.AvaloniaProperty.UnsetValue. Any exception thrown will be treated as an application exception.
ConvertBack(object, Type[], object, CultureInfo)
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
参数
valueobjecttargetTypesType[]parameterobjectcultureCultureInfo
返回
- object[]