【问题标题】:Xamarin Forms XAML - Unable to create multiple images from a list of URLsXamarin Forms XAML - 无法从 URL 列表创建多个图像
【发布时间】:2017-07-15 18:57:50
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: c# xaml xamarin xamarin.forms


    【解决方案1】:
    //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);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-03
      • 2019-10-25
      • 2020-05-12
      • 1970-01-01
      • 2018-05-13
      • 2023-04-04
      • 2018-11-13
      • 1970-01-01
      相关资源
      最近更新 更多