In this recipe, we will learn how to provide an index in a table, allowing the user to quickly browse through the rows of UITableView
.
Create a new project in Xamarin Studio and name it TableIndexApp
. Add a UITableViewController
, as shown in the previous tasks in this chapter, and implement the TableSource
class.
Perform the following step:
In the table source class, override and implement the following methods:
public override int NumberOfSections (UITableView tableView) { return this.tableData.Count; } public override string TitleForHeader (UITableView tableView, int section) { return Convert.ToString (this.tableData[section][0]); } public override string[] SectionIndexTitles (UITableView tableView) { return this.tableData.Select (s => Convert.ToString (s[0])).Distinct ().ToArray (); }