我有一个ItemsControl,它绑定了一个名为Student的集合。 在ItemTemplate中,我有一个使用IValueConverter进行自定义计算和逻辑的TextBox。 我想将实际的Student对象传递给值转换器,而不是其属性。我该如何做?以下是我的代码示例。
<ItemsControl ItemsSource="{Binding StudentList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
<TextBlock Text="{Binding ????, Converter={StaticResource MyConverter}}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
在代码中我有这个
public class MyValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
// I want 'value' to be of type Student.
return null;
}
}