0

我正在尝试将图像从 url 加载到 xamarin 表单应用程序中的图像视图。但我遇到了一个错误,我没有得到修复。

我正在尝试加载图像,如下所示:

ImageService.Instance
            .LoadFile(imageUrl)
            .LoadingPlaceholder("user.png")
            .Into(btn_profile_pic)
            .Source(btn_profile_pic);

我曾尝试仅使用 Into 也仅使用 Source,但出现以下错误:

String does not contain a definition for Into and no extension method 'Into' accepting a first argument of type during could be found

如果我尝试使用 Source,我会收到以下错误:

Non Invocable member TaskParameter.Source cannot be used like a method

btw_profile_pic 是一个图像小部件,我想将图像从 url 加载到图像小部件中。

4

1 回答 1

0

更新:

使用 Xamarin 表单:

XAML

<ffimageloading:CachedImage
        Source="{Binding imageUrl}"
        LoadingPlaceholder="user.png" />

代码:

var yourImage = new CachedImage()
{
    HorizontalOptions = LayoutOptions.FillAndExpand,
    Source = imageUrl,
    Aspect = Aspect.AspectFill,
    LoadingPlaceholder = "user.png"
};

正如您所看到的,没有Into()方法,但您依赖的CachedImage类将为您完成大部分工作。

您需要在每个应用程序项目(iOS、Android 和 UWP)中安装相同的 Form 包,并且需要使用此行来初始化 Renderer。

CachedImageRenderer.Init();

是有关如何使用此库的完整文档。

希望这可以帮助!

于 2017-03-13T05:52:40.027 回答