I set template for item ListView
and assign list items
listView.ItemTemplate = new DataTemplate(typeof(CustomVeggieCell));
listView.ItemsSource = posts;
How to get currentItem
element in CustomVeggieCell
:
CustomVeggieCell.class:
public class CustomVeggieCell : ViewCell
{
public CustomVeggieCell(){
// for example int count = currentItem.Images.Count;
var postImage = new Image
{
Aspect = Aspect.AspectFill,
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
postImage.SetBinding(Image.SourceProperty, new Binding("Images[0]"));
var postImage = new Image
{
Aspect = Aspect.AspectFill,
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
postImage.SetBinding(Image.SourceProperty, new Binding("Images[1]"));
}
}
I want to get amount of Images
in ItemTemplate
. Images
is simply a list of strings.
p.s. All value in ItemTemplate
I get by binding.