Skip to content

Instantly share code, notes, and snippets.

@jfversluis
Created May 8, 2017 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfversluis/b7c7630ad93cef161dff4a96b1d96b2a to your computer and use it in GitHub Desktop.
Save jfversluis/b7c7630ad93cef161dff4a96b1d96b2a to your computer and use it in GitHub Desktop.
Implementation of the TextCellRenderer for my blog post
using System;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer (typeof (TextCell), typeof (RightDetailSample.iOS.TextCellRenderer))]
namespace RightDetailSample.iOS
{
public class TextCellRenderer : Xamarin.Forms.Platform.iOS.TextCellRenderer
{
public override UITableViewCell GetCell (Cell item, UITableViewCell reusableCell, UITableView tv)
{
var textCell = (TextCell)item;
var fullName = item.GetType ().FullName;
var cell = tv.DequeueReusableCell (fullName) as CellTableViewCell;
if (cell == null) {
cell = new CellTableViewCell (UITableViewCellStyle.Value1, fullName);
} else {
cell.Cell.PropertyChanged -= cell.HandlePropertyChanged;
}
cell.Cell = textCell;
textCell.PropertyChanged += cell.HandlePropertyChanged;
cell.PropertyChanged = this.HandlePropertyChanged;
cell.TextLabel.Text = textCell.Text;
cell.DetailTextLabel.Text = textCell.Detail;
UpdateBackground (cell, item);
return cell;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment