Student型のコレクションにバインドされているItemsControlがあります。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;
}
}