2014-09-04 63 views
1

我正在開發WP8應用程序。LongListSelector ItemsPresenter未顯示項目

我有一個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的定義(有和沒有的樣式屬性):

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

使用我用一個ListBox具有相同的風格和相同的ItemTemplate和一切LongListSelector之前一直處於良好工作太很多項目都被加載,迫使應用程序出現OutOfMemoryException。

任何幫助?

回答