【问题标题】:LongListSelector ItemsPresenter not showing itemsLongListSelector ItemsPresenter 不显示项目
【发布时间】:2014-09-04 15:57:53
【问题描述】:

我正在开发一个 WP8 应用。

我有一个 LongListSelector,它显示从 Web 服务获取的项目。 当用户到达列表末尾时,底部必须有一个“加载更多”按钮,以启动 Web 服务并获取更多项目。

列表有这样的样式来显示按钮:

<Style x:Key="DenouncesDistanceList" TargetType="phone:LongListSelector">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="phone:LongListSelector">
                    <ScrollViewer x:Name="ScrollViewer">
                        <StackPanel>
                            <ItemsPresenter />
                            <Button x:Name="LoadMoreToList" Click="LoadMoreToList_Click" >Load moremás</Button>
                        </StackPanel>
                    </ScrollViewer>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

像这样运行应用程序时,手机会显示按钮,但从不显示项目。 如果我取出 LongListSelector 声明中的样式属性,则会显示项目,但会显示在重复项目的永无止境的滚动条上。

这是 LongListSelector 的定义(有和没有 style 属性):

<phone:LongListSelector x:Name="LisByDistanceListBox" ItemTemplate="{StaticResource ReportListDataTemplate}" Margin="0,0,-24,0" Background="{x:Null}" ItemsSource="{Binding ReportsByDistance}" Width="480" Height="476" VerticalAlignment="Top" Style="{StaticResource DenouncesDistanceList}" />

<phone:LongListSelector x:Name="LisByDistanceListBox" ItemTemplate="{StaticResource ReportListDataTemplate}" Margin="0,0,-24,0" Background="{x:Null}" ItemsSource="{Binding ReportsByDistance}" Width="480" Height="476" VerticalAlignment="Top" />

在使用 LongListSelector 之前,我使用的是具有相同样式和相同 ItemTemplate 的 ListBox,并且一切正常,直到加载了太多项目,迫使应用程序引发 OutOfMemoryException。

有什么帮助吗?

【问题讨论】:

    标签: c# wpf windows-phone-8 longlistselector


    【解决方案1】:

    没关系,使用 LongListSelector.ListFooter 解决了这个问题,就像这个答案中所述: https://stackoverflow.com/a/13432573/2686243

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-24
      • 1970-01-01
      • 1970-01-01
      • 2012-12-22
      • 1970-01-01
      • 2012-12-02
      相关资源
      最近更新 更多