I use this custom renderer:
public class ExtViewCellRenderer : ViewCellRenderer
{
UITableViewCell _nativeCell;
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
_nativeCell = base.GetCell(item, reusableCell, tv);
var formsCell = item as ExtViewCell;
if (formsCell != null)
{
formsCell.PropertyChanged -= OnPropertyChanged;
formsCell.PropertyChanged += OnPropertyChanged;
}
SetTap(formsCell);
return _nativeCell;
}
void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
var formsCell = sender as ExtViewCell;
if (formsCell == null)
return;
if (e.PropertyName == ExtViewCell.NoTapProperty.PropertyName)
{
SetTap(formsCell);
}
}
private void SetTap(ExtViewCell formsCell)
{
if (formsCell.NoTap)
_nativeCell.SelectionStyle = UITableViewCellSelectionStyle.None;
else
_nativeCell.SelectionStyle = UITableViewCellSelectionStyle.Default;
}
}
I read that with it is TextCellRendererno longer necessary to explicitly subscribe to the-changed-event property, since there is a basic overridable method HandlePropertyChangedthat can be reused in this context.
Can someone tell me if this is the case for ViewCellRenderer, and if so, how can I change this code to use this?
I also saw this code in another renderer:
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var textCell = (TextCell)item;
var fullName = item.GetType().FullName;
cell = tv.DequeueReusableCell(fullName) as CellTableViewCell;
But not here. Is there any need to do this Cell = tv.DequeueReusableCell?
Alan2 source
share