Tom*_*ski 23 wpf binding relativesource parent
我有ItemsControl绑定到Student类型的集合.在ItemTemplate中我有一个TextBox,它使用IValueConverter来做一些自定义计算和逻辑.我想将实际的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;
        }
} 
Bot*_*000 39
你可以忽略这条路.这样你就可以得到绑定的实际对象.
<TextBlock Text="{Binding Converter={StaticResource MyConverter}}"/>
或者如果你想明确它:
<TextBlock Text="{Binding Path=., Converter={StaticResource MyConverter}}"/>
| 归档时间: | 
 | 
| 查看次数: | 11286 次 | 
| 最近记录: |