I have a list of AvailableItems
that I want to display as a list of checkboxes, so that users can pick which items to generate, which are then stored in another list called ItemsToGenerate
(my lists are actually just lists of strings).
Showing all available items with corresponding checkboxes is easy:
<ItemsControl ItemsSource="{Binding Path=AvailableItems}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
But now I need to bind each Checkbox.IsChecked property, to the fact that the item is in the ItemsToGenerate
list. I thought of making a ListContainmentToBoolConverter
like this:
IsChecked="{Binding Path=ItemsToGenerate,
Converter={StaticResource ListContainmentToBoolConverter}}"
But that doesn't work because I'm missing a ConverterParameter
to pass the value of each item, but I can't do that, because ConverterParameter
does not support binding.
Any ideas?