Is it possible to bind the items of the control within the user control to a property whose name is specified via binding?
Something like this, but without the error produced:
<ItemsControl ItemsSource='{Binding Path=CheckListItems, ElementName=Root}'>
<ItemsControl.ItemTemplate>
<DataTemplate>
<!-- What should I put below to replace the inner binding? -->
<CheckBox Content='{Binding Path={Binding Path=ItemPropertyName, ElementName=Root}, Mode=OneTime}' />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Where
CheckListItems(DP) is a collection of items(IList<SomeCustomContainerType>)ItemPropertyName(DP) is the name of the property within theSomeCustomContainerTypethat should be displayed as a check box textRootis the name of the User Control
The exception in this case is (expectedly) as following:
A 'Binding' cannot be set on the 'Path' property of type 'Binding'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
Basically I want to pass the property name whose text should be displayed in a checkbox somehow from outside. It doesn't have to be bindable, but should be settable from the XAML consuming the user control.