我找不到一个关于在用于 xamarin 表单的 UWP 自定义渲染器中使用 FFImageLoading 的好例子,很好的示例网站仅用于专注于 android 和 ios。我的主要问题是如何在 UWP 资源中使用这个 Image Class,如果我理解正确,应该在 PCL 项目中使用 CachedImage。那么我应该如何继续在这里?ImageService 的提前使用并没有详细说明这一点。我可能不明白一些事情。提前致谢。
这是我在 PCL 中的查看单元:
<ViewCell>
<Grid RowSpacing="0" Padding="5,1,10,1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="30"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="32"></RowDefinition>
<RowDefinition Height="32"></RowDefinition>
</Grid.RowDefinitions>
<ffimageloading:CachedImage Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Source="{Binding MyViewModel.Image}" Aspect="AspectFit" VerticalOptions="Center" LoadingPlaceholder = "resource://MyProject.Resources.loading.png" />
<Label Grid.Column="1" Grid.Row="0" Text="{Binding MyViewModel.Name}" FontSize="16" TextColor="Red" FontAttributes="Bold" VerticalOptions="End"></Label>
<Label Grid.Column="1" Grid.Row="1" Text="{Binding MyViewModel.Serie}" FontSize="11" TextColor="Gray" FontAttributes="Italic" VerticalOptions="Start"></Label>
<ffimageloading:CachedImage x:Name="check" Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" Source="{Binding MyViewModel.Own, Converter={StaticResource BoolToOwnImageSourceConverter}}}" Aspect="AspectFit" VerticalOptions="Center">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="OnCheckTapped"
Command="{Binding ChangeOwnCommand}"
CommandParameter="{Binding .}"/>
</Image.GestureRecognizers>
</ffimageloading:CachedImage>
</Grid>
<ViewCell.ContextActions>
<MenuItem Clicked="OnOwned" CommandParameter="{Binding .}" Text="Got it!" />
<MenuItem Clicked="OnNotOwned" CommandParameter="{Binding .}" Text="Not Yet" IsDestructive="True" />
</ViewCell.ContextActions>
图像源来自存储在我的视图模型中的图像 url