为什么LonglistSelector不显示项目,虽然它显示GroupHeaderItem? [英] Why LonglistSelector not display items though it display GroupHeaderItem?

查看:60
本文介绍了为什么LonglistSelector不显示项目,虽然它显示GroupHeaderItem?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

My LonglistSelector only displays GroupHeaderTemplate Data (ImageSource,Title) but ItemTemplate DataTemplate (SubItemTitle, Location) not displayed. How can i solve it?




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>

推荐答案

ItemTemplate的DataTemplate中没有ListBox或任何内容。例如,请参阅下面的DataTemplate:



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

<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>


这篇关于为什么LonglistSelector不显示项目,虽然它显示GroupHeaderItem?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆