2017-03-13 50 views
0

我试图从URL加载图像到Xamarin窗体应用程序中的图像视图。但是我收到一个错误,我没有得到一个修复。Xamarin窗体:无法使用FFImageLoading库加载图像

我试图加载图片,如下图所示:

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

我一直在使用只进,也只有源试过,但我得到以下错误:

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

如果我尝试使用源我得到以下错误:

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

btw_profile_pic是一个图像小部件,我想加载t他从url映像到图像小部件。

回答

0

UPDATE:

使用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(); 

Here是如何使用这个库的完整文档。

希望这会有所帮助!

+0

我的坏,抱歉,我编辑了这个问题,它是复制粘贴错误。即使在添加括号后,我也会得到相同的错误。 – focus