Hi guys, I'm trying to customize a ViewCell and I did it already in Android.
I'm following this example https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/viewcell/ and this: because in iOS, I want to use a storyboard.
So, I have the following code for the moment:
[assembly: ExportRenderer(typeof(CustomTableViewCell), typeof(NativeiOSCellRenderer))]
namespace Namespace
{
public class NativeiOSCellRenderer : ViewCellRenderer
{
ControllerCell cell;
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var nativeCell = (CustomTableViewCell)item;
Console.WriteLine("\t\t" + nativeCell.SpeakerName);
cell = reusableCell as ControllerCell;
if (cell == null)
{
cell = new ControllerCell(item.GetType().FullName, nativeCell);
}
//else
//{
// cell.NativeCell.PropertyChanged -= OnNativeCellPropertyChanged;
//}
//nativeCell.PropertyChanged += OnNativeCellPropertyChanged;
cell.UpdateCell(nativeCell);
return cell;
}
}
The PropertyChanged is not implemented yet, and in ControllerCell I have the following code:
public partial class ControllerCell : UITableViewCell
{
public CustomTableViewCell NativeCell { get; private set; }
public Element Element => NativeCell;
public ControllerCell (IntPtr handle) : base (handle)
{
}
public ControllerCell(string cellId, CustomTableViewCell cell) : base(UITableViewCellStyle.Default, cellId)
{
NativeCell = cell;
}
public void UpdateCell(CustomTableViewCell cell)
{
if (cell.SpeakerName != "")
{
SpeakerNameLabel.Text = cell.SpeakerName;
}
TitleConferenceLabel.Text = cell.TitleName;
ConferenceHourLabel.Text = cell.ConferenceHour;
}
}
And in CustomTableViewCell I have the same things like in the example from Xamarin site.
The problem is that SpeakerNameLabel.Text, TitleConferenceLabel.Text and ConferenceHourLabel.Text are null.
What I am missing? What can I do more? I can't find my answer anywhere, so maybe I can find some help here. Thanks!
PS. Sorry for my bad code formatting.