将嵌套的ListBox绑定到嵌套的List?

Wal*_*tiD 6 wpf listbox itemtemplate

我有以下ViewModel-Property:

public List<List<string>> Names .... //It's a dependency property
Run Code Online (Sandbox Code Playgroud)

在我看来,我希望ItemsControl有一个ItemsControl:

 <ItemsControl ItemsSource="{Binding Names}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <ItemsControl ItemsSource="{Binding ?????}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Label Text="{Binding ??????}" />
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
Run Code Online (Sandbox Code Playgroud)

我如何绑定到的项目List?在上面的代码示例中,我标记了它?????

sll*_*sll 6

只需使用绑定到当前绑定源:

ItemsSource="{Binding}"
Run Code Online (Sandbox Code Playgroud)

请参阅以下评论:

<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>
Run Code Online (Sandbox Code Playgroud)