【发布时间】:2017-07-15 18:57:50
【问题描述】:
我有一个列表,其中字符串是图像的 url。
我正在尝试动态创建一个图像网格,源是每个 url。
我尝试过绑定,但它似乎不起作用。我也无法访问我在 Xaml 中创建的图像的 x:Name。我愿意在 Xaml 或后面的代码中执行此操作。
关于如何做到这一点的任何想法。
【问题讨论】:
标签: c# xaml xamarin xamarin.forms
我有一个列表,其中字符串是图像的 url。
我正在尝试动态创建一个图像网格,源是每个 url。
我尝试过绑定,但它似乎不起作用。我也无法访问我在 Xaml 中创建的图像的 x:Name。我愿意在 Xaml 或后面的代码中执行此操作。
关于如何做到这一点的任何想法。
【问题讨论】:
标签: c# xaml xamarin xamarin.forms
//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);
}
【讨论】: