views:

235

answers:

1

I have the following XAML. Let's say FruitList is a collection of Fruits, each of which has a collection of FruitSeeds. Is there a syntax to bind cbxFruitSeeds to a collection of FruitSeeds, depending on which Fruit is selected in cbxFruits?

<GridView>

    <GridViewColumn Header="Fruits">

        <GridViewColumn.CellTemplate>

            <DataTemplate>

                <ComboBox DisplayMemberPath="Fruit.Name" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}, Path=DataContext.FruitList}" x:Name="cbxFruits"/>

            </DataTemplate>

    </GridViewColumn.CellTemplate>

</GridViewColumn>

    <GridViewColumn Header="FruitSeeds">

        <GridViewColumn.CellTemplate>

            <DataTemplate>

                <ComboBox x:Name="cbxFruitSeeds"></ComboBox>

            </DataTemplate>

        </GridViewColumn.CellTemplate>

    </GridViewColumn>

</GridView>
A: 

It looks like you're trying to do a cascading combobox.

http://stackoverflow.com/questions/202990/is-there-really-no-way-to-follow-up-dataset-parent-relation-in-xaml-binding shows how to do a parent-child set up in xaml.

Donnelle