TheJoeIaut
TheJoeIaut

Reputation: 1532

Binding Path hierarchy

I developed a Usercontrol that takes a Measurement Object. Each Measurement Object has a List of Cell Objects and each Cell Object has a List of Station Objects.

The Usercontrol generates a TextBox for each Station. Currently I set the DataContext for each Station to a certain Station and the BindingPath to my Value Member.

This works but when I try to display a different Measurement I have to set the Bindings to the Stations of the new Measurement.

I'd like to achieve, setting a BindingPath in a way that only the DataContext of the Usercontrol has to be set to the new Measurement and all Textboxes take the new Bindings.

Is this possible?

Upvotes: 1

Views: 101

Answers (1)

Dean Chalk
Dean Chalk

Reputation: 20461

Im not sure I entirely understand your problem, but from what Im guessing, you may be looking for something like this:

<ItemsControl ItemsSource="{Binding Path=Cells}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <ItemsControl ItemsSource="{Binding Path=Stations}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBox Text="{Binding Value}" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

Upvotes: 1

Related Questions