0

I have those two classes:

class DownloadLink
{
    public string Name { get; private set; }
    public string Url { get; private set; }
    //(...)
}

class DownloadGroup
{        
    public List<DownloadLink> Links { get; private set; }
    //(...)
}

class Manager
{
    public List<DownloadGroup> Groups { get; private set; }
}

Manager managerOBJ = new Manager();

I want to display this like that:

Everything will be in ListBox: I wan to bind managerOBJ.Groups to that ListBox. - How to do it? Than I want to create DataTamplate to display each group and all links in that group. - How to do it?

I want to do as much as possible from XAML

UPDATE:

This is what I got. It's not workig. List box is empty.

    <ListBox DockPanel.Dock="Right" VerticalAlignment="Stretch" Width="500" HorizontalAlignment="Right" Background="#FFE1FFF5" HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible" ItemsSource="{Binding Path=Groups}" Name="GroupsListBox">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Height="30" VerticalAlignment="Top" Width="500" >
                    <Grid Height="Auto" Width="500">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Label Content="XX MB w XX plikach" HorizontalAlignment="Stretch" Margin="0"/>
                    </Grid>
                    <ListBox HorizontalAlignment="Stretch" Height="43" Margin="0,5,0,0" Width="Auto" VerticalAlignment="Top" ItemsSource="{Binding Path=Links}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Label Content="{Binding Path=Name}" />
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

and in code behid I have:

RapideoAccount = new Rapideo();
GroupsListBox.DataContext = RapideoAccount;
1
  • Look at the Related questions shown to the right of your question. You've been asking lots of repetitive questions that are getting closed. Boring us all to tears, frankly. You'd better watch out for the feared User Ban Script, meta.stackexchange.com/questions/56817/… Commented Mar 21, 2011 at 17:02

2 Answers 2

1

The whole manager is contained in a listbox, for each downloadgroup in the manager you add an itemscontrol that contains another items control with the links in it. This can be done by using DataTemplates:

    <ListBox Name="myGroups"
         ItemsSource="{Binding Path=Groups}">
    <!-- each List<DownloadGroup> in the manager: -->
    <ListBox.ItemTemplate>
        <DataTemplate>
            <ItemsControl ItemsSource="{Binding Path=Links}">
                <!-- each Link in the Downloadgroup -->
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding Path=Name}" />
                            <TextBlock Text="{Binding Path=Url}" />
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

In code you would put:

Manager managerOBJ = new Manager();
myGroups.DataContext = managerOBJ;
Sign up to request clarification or add additional context in comments.

1 Comment

What exactly is a Rapideo, is that the Manager you had earlier?
0
  1. define managerOBJ as a property in your viewmodel
  2. binding viewmodel to your view.
  3. binding ListBox itemssource to managerOBJ.Groups.
  4. define DataTemplate inside ListBox to display each DownloadGroup.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.