Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
My LonglistSelector only displays GroupHeaderTemplate Data (ImageSource,Title) but ItemTemplate DataTemplate (SubItemTitle, Location) not displayed. How can i solve it?

XML
public class Data
    {
        public string Title { get; set; }
        public string ImageSource { get; set; }
        public List<SubItem> SubItems { get; set; }
        public Data()
        {
            SubItems = new List<SubItem>();
        }

    }
    public class SubItem
    {
        public string SubItemTitle { get; set; }
        public string Location { get; set; }
    }
<phone:LongListSelector ItemsSource="{Binding DataCollection}" Grid.Row="0" IsGroupingEnabled="True">
            <phone:LongListSelector.GroupHeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Margin="10">
                        <Image Source="{Binding ImageSource}"/>
                        <TextBlock Text="{Binding Title}"/>
                    </StackPanel>
                </DataTemplate>
            </phone:LongListSelector.GroupHeaderTemplate>
            <phone:LongListSelector.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding SubItemTitle}" Padding="5" FontSize="40"/>
                            <TextBlock Text="{Binding Location}" Padding="5" FontSize="40"/>
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </phone:LongListSelector.ItemTemplate>
        </phone:LongListSelector>
Posted

1 solution

There is no ListBox or anything in the DataTemplate for the ItemTemplate. For example, see the DataTemplate below:

XML
<phone:longlistselector itemssource="{Binding DataCollection}" grid.row="0" xmlns:phone="#unknown">
    <phone:longlistselector.itemtemplate>
        <DataTemplate>
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Title}" Padding="5" />
                    <TextBlock Text="{Binding ImageSource}" Padding="5"/>
                </StackPanel>
                <ListBox ItemsSource="{Binding SubItems}">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Vertical"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding SubItemTitle}" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </StackPanel>
        </DataTemplate>
    </phone:longlistselector.itemtemplate>
</phone:longlistselector>
 
Share this answer
 
Comments
suzand 5-Sep-14 1:15am    
I've tried this way, but there is limitation here, when "SubItems" contain large number of item I can only scroll listBox item but not LonglistSelector items. is it possible to do so using LonglistSelector only.
suzand 29-Sep-14 6:20am    
Is nobody there to give me suggestion!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900