首页 > 解决方案 > 当itemsource是图像时如何修复xamarin表单listview滞后

问题描述

当 itemsource 是图像时如何修复 xamarin 表单列表视图滞后。图像来自文件夹路径我使用 FFimageloading 进行图像显示


 <ffimageloading:CachedImage Aspect="AspectFill"
                             HorizontalOptions="FillAndExpand"
                             VerticalOptions="FillAndExpand"
                             BitmapOptimizations="True"
                             DownsampleToViewSize="True"
                             DownsampleUseDipUnits="True"
                             CacheDuration="80"
                             CacheType="Memory"  
                             LoadingPlaceholder="ic_timer"
                             ErrorPlaceholder="ic_spare_active"
                             Source="{Binding DocumentUrl}">

<ffimageloading:CachedImage.Triggers>
      <DataTrigger Binding="{Binding IsAddDocumentItem}"
                   TargetType="ffimageloading:CachedImage"
                   Value="True">

       <Setter Property="IsVisible" Value="False"/>

      </DataTrigger>

</ffimageloading:CachedImage.Triggers>

</ffimageloading:CachedImage>

标签: c#xamarin

解决方案


如果启用下采样,请确保为 DownsampleWidth 或 DownsampleHeight 设置正确的值。FFImageLoading 仅使用其中一种,保持正确的纵横比。

添加和CachingStrategy="RecycleElement"到 ListView

在这里查看更多样品

https://github.com/luberda-molinet/FFImageLoading/tree/master/samples/ImageLoading.Forms.Sample/Shared/Pages


推荐阅读