1

The following Control is bound to a List of Users:

<ItemsControl x:Name="Users">
      <ItemsControl.ItemTemplate>
        <DataTemplate>

How can I pass the user to a Converter in this case, not just properties of it?

errorcode007
  • 321
  • 1
  • 4
  • 11

1 Answers1

4

I assume you're referring to an IValueConverter instance? Just leave out the Path parameter of your Binding and it will pass in the current DataContext (in your case a User instance).

This sample assumes your IValueConverter is called MyValueConverter:

<ItemsControl x:Name="Users">
      <ItemsControl.ItemTemplate>
        <DataTemplate>
           <TextBox Text="{Binding Converter={StaticResource MyValueConverter}}" />
        </DataTemplate>
      <ItemsControl.ItemTemplate>
</ItemsControl>
Steve Danner
  • 21,818
  • 7
  • 41
  • 51