Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

ListView ImageCell Renderer

$
0
0

I am trying to create a Renderer for Android, IOS and Windows Phone for the ImageCell template to be used in a ListView. I'd like to add a second and third image to the cell and set their sources, but have not figured out how to do that.

Looking at the Hanselman Forms example for Android, I got the basic idea on how to create a renderer for the ImageCell
https://github.com/jamesmontemagno/Hanselman.Forms/blob/master/Hanselman.Android/Renderers/ListImageCellRenderer.cs

I assume that I can add a second ImageView in the Renderer with

var secondImage = new ImageView();
cell.AddView(secondImage, 1);

and something similar with iOS, WP

Once I do this, how can I set the image source in Xamarin.Forms DataTemplate?
Something like this

var cell = new DataTemplate(typeof(DarkTextCell));
cell.SetBinding(TextCell.TextProperty, "Title");
cell.SetValue(TextCell.TextColorProperty, Color.White);
cell.SetValue(ImageCell.ImageSourceProperty, "image1");//Set the main image source
cell.SetValue(ImageCellCustom.SecondImageSourceProperty, "image2"); //Set the second image source
cell.SetValue(TextCell.DetailColorProperty, Color.FromHex("cccccc"));
cell.SetValue(BackgroundColorProperty, Color.Transparent);

The reason I want to do this is performance, currently I am creating a ViewCell and is extremely slow when scrolling in both Android and iOS.


Viewing all articles
Browse latest Browse all 58056

Trending Articles