Binding.Converter是可以解决你的问题,比如这样:
public class DictionaryItemConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var dict = value as Dictionary<string, string>;
if (dict != null)
{
return dict[parameter as string];
}
throw new NotImplementedException();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}<br/>
<local:DictionaryItemConverter x:Name="DictConvert" />
<TextBlock Text="{Binding Converter={StaticResource DictConvert}, ConverterParameter=test}" />
Best regards,
Sheldon _Xiao[MSFT]
MSDN Community Support |
Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
![]()