c# - Xamarin Forms XAML - 无法从 URL 列表创建多个图像

标签 c# xaml xamarin xamarin.forms

我有一个列表,其中字符串是图像的 url。

我正在尝试动态创建图像网格,源是每个 url。

我尝试过绑定(bind),但它似乎不起作用。我也无法访问我在 Xaml 中创建的图像的 x:Name。我愿意在 Xaml 或后台代码中执行此操作。

关于如何做到这一点的任何想法。

最佳答案

//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);
}

关于c# - Xamarin Forms XAML - 无法从 URL 列表创建多个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45121717/

相关文章:

c# - 解析来自 Httpwebrequest 的 Json 响应

c# - 违反通用参数约束?

android - XML dp 不同于计算的 dp (dip)

c# Marshal 以 null 结尾的字符串数组

c# - 更改文本文件中特定行中的特定文本

c# - 在 c# 中向应用程序发送击键(sendkeys、postmessage、sendmessage 都不起作用)

c# - UWP 专注于 AutoSuggestBox

wpf - 自动生成的 view.g.cs 页面一直包含旧的 using 语句?

ios - 使用 Google Map sdk iOS Xamarin 显示所有标记

C# - Xamarin Forms 音频播放器在使用 5 或 6 次后停止工作