This section describes adding a C1AutoComplete control to your iOS application and populating it with data. The data is shown as a list in the drop-down part of the control.
Complete the following steps to display a C1AutoComplete control.
The following image shows a C1AutoComplete control displaying input suggestions as the user types.
Add a new class to the application that serves as the data source for C1AutoComplete.
C# |
Copy Code
|
---|---|
class Countries : NSObject { [Export("Name")] public string Name { get; set; } public Countries() { this.Name = string.Empty; } public Countries(string name) { this.Name = name; } public static IEnumerable<object> GetDemoDataList() { List<object> array = new List<object>(); var quarterNames = "Australia,Bangladesh,Brazil,Canada,China".Split(','); for (int i = 0; i < quarterNames.Length; i++) { array.Add(new Countries { Name = quarterNames[i] }); } return array as IEnumerable<object>; } } |
To initialize C1AutoComplete control, open the ViewController file from the Solution Explorer and replace its content with the code below. This overrides the ViewDidLoad method of the View controller in order to initialize C1AutoComplete.
C# |
Copy Code
|
---|---|
public override void ViewDidLoad() { base.ViewDidLoad(); HighlightDropdown.DropDownHeight = 200; HighlightDropdown.DisplayMemberPath = "Name"; HighlightDropdown.IsAnimated = true; HighlightDropdown.ItemsSource = Countries.GetDemoDataList(); } |
Press F5 to run your application