I am trying to create a AutoComplete Text Entry using Xamarin Forms. Can anybody help me in creating a custom renderer for the auto complete text field in C#. I am using MVVM concept.
You can achieve it using the following components.
An Entry field with TextChanged Event. A ListView which to display the data set. As a first step you can create the Entry and ListView in a StackLayout with Vertical alignment. Set ItemSource of the ListView to your data set. Add the following code in your function for TextChanged event
void OnTextChanged(object sender, EventArgs args)
{
Site_listView.ItemsSource = vm.SiteList.Where(x => x.siteName.ToLower().Contains(siteNameEntry.Text.ToString().ToLower())).ToList();
}
Site_listView, siteNameEntry are the x:Name of ListView and Entry respectively
You can use ItemSelected/ItemTapped events in the list view for selecting the item from the list and assigning it to the Entry. Also you can use Focused, UnFocused events also to set the visibility of the list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With