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?
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?
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>