I have to work with a UserControl, that I cannot change. The Datacontext of this UserControl is set to itself in its constructor.
public ParameterControl()
{
Datacontext = this;
}
The UserControl should be the template of my ListBox-Items.
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<parameterControl:ParameterControl
DataContext="{Binding ElementName=StepView, Path=Datacontext.SelectedStep}" //this doesn't work
</parameterControl:ParameterControl>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
My implemented binding for the datacontext doesn't work.
Does anyone know how I can solve this problem or tell me at what point of time the datacontexts are set?
Thanks for help, Alex
EDIT:
Hi again,
there is no chance to rebuild the ParameterControl. I've got this idea...
<ListBox
ItemsSource="{Binding Parameters}"
<ListBox.ItemTemplate>
<DataTemplate>
<parameterControl:ParameterControl
ParamName="{Binding <!--To the item in the ItemsSource-Collection-->}"
</parameterControl:ParameterControl>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The parameter Control needs only the name for the ParamName property to be displayed correctly. And this name is in the item of the ItemsSource-Collection.
Do anyone now how to bind?
Thanks for help, Alex