Binding Listbox item source to a collection of collections in windows phone 7

Posted by Tee on Stack Overflow See other posts from Stack Overflow or by Tee
Published on 2010-12-21T17:49:54Z Indexed on 2010/12/21 17:54 UTC
Read the original article Hit count: 194

Hi there,

I am trying to bind a Listbox ItemSource to a collection of multiple Lists. i.e.

List PersonCollection

  • List Person

  • List Collection

Now I need to show items from both of these list. In wpf you could use HierarchicalDataTemplate i believe, but not sure how I can do it in windows phone 7. Tried with Blend and it generates the following data template.

<DataTemplate x:Key="PersonDataTemplate">
                    <Grid>
                            <StackPanel Margin="0,0,1,0" Orientation="Vertical" VerticalAlignment="Top">
                                    <TextBlock Margin="0,0,1,0" TextWrapping="Wrap" Text="{Binding Person[0].Name}" d:LayoutOverrides="Width"/>
                                    <TextBlock Margin="0,0,1,0" TextWrapping="Wrap" Text="{Binding Collection[0].Total}" d:LayoutOverrides="Width"/>
                            </StackPanel>
                    </Grid>
            </DataTemplate> 

Is there another way I can do this? I have tried to set the DataContext of Textbox in DataTemplate to individual arrays but did not seem to work. Cant find anything similar on the net apart from the confirmation that HierarchicalDataTemplate is not supported in Windows Phone 7.

I have other ways to do but none elegant..

Thanks in advance.

Regards

© Stack Overflow or respective owner

Related posts about xaml

Related posts about databinding