Skip to content

Instantly share code, notes, and snippets.

@aybarsyalcin
Last active March 17, 2022 22:53
Show Gist options
  • Save aybarsyalcin/0aed32e43d8cc2d17d42da5bb9107227 to your computer and use it in GitHub Desktop.
Save aybarsyalcin/0aed32e43d8cc2d17d42da5bb9107227 to your computer and use it in GitHub Desktop.
Xamarin.Forms Get All Cell on Listview
IEnumerable<PropertyInfo> pInfos = (xListView as ItemsView<Cell>).GetType().GetRuntimeProperties();
var templatedItems = pInfos.FirstOrDefault(info => info.Name == "TemplatedItems");
if (templatedItems != null)
{
var cells = templatedItems.GetValue(xListView);
Xamarin.Forms.ITemplatedItemsList<Xamarin.Forms.Cell> listCell = cells as Xamarin.Forms.ITemplatedItemsList<Xamarin.Forms.Cell>;
ViewCell currentCell = listCell[position] as ViewCell;
currentCell.View.BackgroundColor = Color.White;
foreach (ViewCell cell in cells as Xamarin.Forms.ITemplatedItemsList<Xamarin.Forms.Cell>)
{
if (cell.BindingContext != null && currentCell != cell)
{
cell.View.BackgroundColor = Color.Transparent;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment