I really donβt understand the problem you are seeing right now.
However, I can explain how I used sections in BaseSessionListView.cs in a conference example.
Basically, in this example, the ItemsSource was a grouped source, so the ViewModel code was:
public class SessionGroup : List<Session> { public string Key { get; set; } public SessionGroup(string key, IEnumerable<Session> items) : base(sessions) { Key = key; } } private List<SessionGroup> _groupedList; public List<SessionGroup> GroupedList { get { return _groupedList; } protected set { _groupedList = value; RaisePropertyChanged("GroupedList"); } }
This meant that my exposed ItemSource was a bit like:
Group Session Session Session Group Session Session Session Session Group Session Session etc
The methods based on Section in the table source were as follows:
public override string[] SectionIndexTitles(UITableView tableView) { if (_sessionGroups == null) return base.SectionIndexTitles(tableView); return _sessionGroups.Select(x => KeyToString(x.Key, 10)).ToArray(); } protected override object GetItemAt(NSIndexPath indexPath) { if (_sessionGroups == null) return null; return _sessionGroups[indexPath.Section][indexPath.Row]; } public override int NumberOfSections(UITableView tableView) { if (_sessionGroups == null) return 0; return _sessionGroups.Count; } public override int RowsInSection(UITableView tableview, int section) { if (_sessionGroups == null) return 0; return _sessionGroups[section].Count; }
It seemed to work ... but I donβt know if this helps your question?
If I wanted to add a title element, then probably I would just change the RowsInSection and GetItemAt methods to place this - plus GetOrCreateCellFor to return the title element elements too ... but I think there will be other ways to do this?
source share