Mono project: How do I assign a C# generic list as a TableView's datasource?
-
13-12-2019 - |
Question
I try to do this, with no luck:
private List<Person> mPeople = new List<Person>();
public List<Person> People
{
get {return mPeople;}
set {mPeople=value;}
}
partial void CreatePeople (MonoMac.Foundation.NSObject sender)
{
CreateThePeople ();
tableView.DataSource=mPeople;
tableView.ReloadData ();
}
I receive a "Cannot implicitly convert type..." error on the DataSource line. Using an explicit conversion doesn't work, either.
From the bit I understand about XCode development, I'm to stretch a line from my class to the datasource property of the grid in interface builder, but the problem with this is that I can't assign my class to one of the icons in the center of the display (where the File Ownder and First Responder icons are located).
I'm using XCode 4 on Mac Lion.
Hopefully this is clear enough. Can someone point me in the right direction? Thanks in advance.
EDIT: After some more searching I found http://www.netneurotic.net/Mono/MonoMac-NSTableView.html, which suggests that I will always need to create a class which inherits from NSTableViewDataSource. This will work for me, but before I let this go, is this the preferred way of doing it (if a preferred way even exists)? Thanks again.
Solution
Not only is that the "preferred" way of doing it, it's the only way of doing it.