我正在开发一个WP8应用程序。
我有一个LongListSelector,它显示从web服务中获取的项。当用户到达列表的末尾时,必须在底部有一个"Load more“按钮,以获取更多的项目。
列表的样式如下所示:
<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声明中的style属性,就会显示这些项,但是在重复这些项的永无止境的滚动中会显示这些项。
这是LongListSelector的定义(有和没有样式属性):
<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。
有什么帮助吗?
发布于 2014-09-04 18:21:35
没关系,用LongListSelector.ListFooter来解决这个问题,就像在这个答案上所说的:https://stackoverflow.com/a/13432573/2686243
https://stackoverflow.com/questions/25669991
复制相似问题