Binding a nested ListBox to a nested List? Binding a nested ListBox to a nested List? wpf wpf

Binding a nested ListBox to a nested List?


Simply use binding to the current Binding Source:

ItemsSource="{Binding}"

See some comments below:

<ItemsControl ItemsSource="{Binding Names}">        <ItemsControl.ItemTemplate>            <DataTemplate>                <! -- Here is the current binding source will be inner                      List<string>                 -->                <ItemsControl ItemsSource="{Binding}">                    <ItemsControl.ItemsPanel>                        <ItemsPanelTemplate>                            <StackPanel Orientation="Horizontal" />                        </ItemsPanelTemplate>                    </ItemsControl.ItemsPanel>                    <! -- Here is the current binding wource will be                           a string value from the inner List<string>                    -->                    <ItemsControl.ItemTemplate>                        <DataTemplate>                            <Label Text="{Binding}" />                        </DataTemplate>                    </ItemsControl.ItemTemplate>                </ItemsControl>            </DataTemplate>        </ItemsControl.ItemTemplate>    </ItemsControl>