WPF - Use ItemsControl within ItemsControl

7

I'm having a somewhat strange problem. To begin with I have these two classes:

public class Server
{
    public Guid id { get; set; }
    public string descripcion { get; set; }
    public string nombre { get; set; }
    public List<PathSync> carpetas { get; set; }
}

public class PathSync
{
    public Guid id { get; set; }
    public string origen { get; set; }
    public string destino { get; set; }
    public int tipocopia { get; set; }
}

In my application I create a list of Server objects and initialize them, also creating the list of PathSync objects inside each object. Once I have this list created, I initialize ItemsControls with collapsedPanelItem.ItemsSource = lista .

Then, in my WPF application, in the view, I have the following block:

<ItemsControl x:Name="collapsedPanelItem">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Expander Header="{Binding nombre}">
                <StackPanel Margin="10" Orientation="Vertical">
                    <TextBlock TextWrapping="Wrap" Text="{Binding descripcion}" />
                    <ItemsControl ItemsSource="{Binding carpetas}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical">
                                    <Label Content="{Binding origen}" />
                                    <Label Content="{Binding destino}" />
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </StackPanel>
            </Expander>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

When I run my application I get the list of drop-down lists showing the name and, when I display it, I see the label inside with the description, but the second ItemsControl does not show the list of folders.

Does anyone know what I'm doing wrong?

    
asked by Alejandro 31.01.2018 в 09:46
source

0 answers