Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

System.NullReferenceException: Object reference not set to an instance of an object

$
0
0

I am following the tutorial on

https://docs.microsoft.com/en-us/xamarin/ios/user-interface/controls/tables/populating-a-table-with-data

ViewController:

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        LiveTrackTableView.RegisterClassForCellReuse(typeof(LiveTrackTableCell), CellId);
        DataSource tableSource = new DataSource();
        LiveTrackTableView.Source = tableSource;

    }

TableView:

    public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
    {
        // if cell is not available in reuse pool, iOS will create one automatically
        // no need to do null check and create cell manually
        var cell = (LiveTrackTableCell)tableView.DequeueReusableCell(HomePageLiveTrackController.CellId, indexPath);
        cell.UpdateCell(indexPath);

        return cell;
    }

CellView:

public partial class LiveTrackTableCell : UITableViewCell
{
    public LiveTrackTableCell (IntPtr handle) : base (handle)
    {
    }

    internal void UpdateCell(NSIndexPath indexPath)
    {
        Console.WriteLine(ThreadTitle.Text);

}
}

The error occurs where "Console.WriteLine(ThreadTitle.Text);" is at. The label is created in xamarin storyboard, how do I instantiate the label in code?


Viewing all articles
Browse latest Browse all 204402

Trending Articles