2017-07-15 95 views
1

我有一个List,其中的字符串是图像的URL。Xamarin Forms XAML - 无法从URL列表中创建多个图像

我想动态地创建一个图像的网格与来源是每个网址。

我已经尝试绑定,但它似乎并没有工作。我也无法访问我在Xaml中创建的图像的名称。我愿意在Xaml或后面的代码中这样做。

任何想法如何做到这一点。

回答

2
//imageList is a List<string> with your image urls in it 
foreach(var i in imageList) { 
    Image image = new Image(); 
    image.Source = ImageSource.FromUri(new Uri(i)); 

    // you will need to add logic to calculate the Row/Column for each image 
    myGrid.Children.Add(image,x,y); 
} 
+1

这是完美的!谢谢! –