簡體   English   中英

LongListSelector ItemsPresenter不顯示項目

[英]LongListSelector ItemsPresenter not showing items

我正在開發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聲明上的style屬性,則顯示項目,但在重復該項目的永無止境的滾動中。

這是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。

有什么幫助嗎?

沒關系,請使用LongListSelector.ListFooter解決此問題,如此答案中所述: https ://stackoverflow.com/a/13432573/2686243

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM