Created
May 8, 2017 10:42
-
-
Save jfversluis/b7c7630ad93cef161dff4a96b1d96b2a to your computer and use it in GitHub Desktop.
Implementation of the TextCellRenderer for my blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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