1

目前,我的视图绑定到后面代码中的数据,以便在列表框中显示带有 2 个子标题的图片。但是,当我加载大量记录时,Windows Phone 内存不足。我已经让应用程序一次只加载 10 条记录,所以当用户向下滚动时,会加载 10 条以上等。但问题是当用户加载 200 条或更多记录时手机仍然内存不足,并且有大约有2600条记录。

  <ListBox x:Name="geklassifisseerd_list" 
                         VerticalAlignment="Top"
                         ItemsSource="{Binding ClassifiedAds}"
                         SelectionChanged="geklassifisseerd_list_SelectionChanged_1"
                         Grid.Row="1">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="5">
                                <Image Source="{Binding ImageUrl}" 
                                   Height="140"
                                   Width="160"/>

                                <TextBlock Text="{Binding Title}" 
                                       TextWrapping="Wrap" 
                                       Margin="2" 
                                       Width="160"
                                       Foreground="Black"
                                       FontWeight="Bold"
                                       FontSize="15"/>

                                <TextBlock Text="{Binding CreationDate}" 
                                       TextWrapping="Wrap" 
                                       Foreground="Black"
                                       Margin="2,0,0,5" 
                                       FontSize="13"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>

                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <Controls:WrapPanel Orientation="Horizontal"  />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>

该模型 :

 public class ClassifiedAds : INotifyPropertyChanged
{
    public int ID { get; set; }
    public string Title { get; set; }

    private string _body;
    public string Body
    {
        get { return _body; }
        set { _body = HTMLHelper.ConvertHtmlToText(value); }
    }

    public string CategoryName { get; set; }
    public string ContactEmail { get; set; }
    public string ContactTel { get; set; }
    public DateTime CreationDate { get; set; }
    public DateTime DisplayUntilDate { get; set; }
    public Gal Gallery { get; set; }
    public string ImageUrl { get; set; }
    public bool IsActive { get; set; }
    public bool IsDeleted { get; set; }
    public DateTime LastUpdateDate { get; set; }
    public string PhysicalAddress { get; set; }
    public string Price { get; set; }
    public string ProvinceName { get; set; }
    public int TotalViews { get; set; }

    public event PropertyChangedEventHandler PropertyChanged;

    private void RaisePropertyChanged(string propertyName)
    {
        if (this.PropertyChanged != null)
        {
            this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

我不知道我还能如何加载数据,因为需要显示所有记录,是否可以在用户向下滚动时卸载以前的记录?或者也许我可以尝试其他的东西?

4

0 回答 0