Xamarin.Forms.ComboBox

Simple Xamarin Forms combo box with search option


Keywords
Install
Install-Package Xamarin.Forms.ComboBox -Version 1.0.0.3

Documentation

Xamarin.Forms.ComboBox

Simple Xamarin Forms combo box with search option

Features

  • Completely PCL, without any platform specific code, only entry and list view controls were used
  • Material compatible
  • Search option, complete control on how the search is performed
  • Item template to customize how items in combobox are displayed

Nuget package

Available as nuget package at https://www.nuget.org/packages/Xamarin.Forms.ComboBox/ Install it in shared code project.

Usage

Create the control like so:

<ComboBox x:Name="ComboBox" ItemsSource="{Binding ItemsSource}" Placeholder="{Binding Placeholder}" SelectedItem="{Binding SelectedItem}" SelectedItemChanged="ComboBox_SelectedItemChanged" TextChanged="ComboBox_TextChanged" Visual="Material"> <ComboBox.ItemTemplate> <DataTemplate> <ViewCell> <Label Text="{Binding .}" Padding="5,5,0,0"/> </ViewCell> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>

Hookup text changed event to perform filtering, ex.:

private void ComboBox_TextChanged(object sender, TextChangedEventArgs e) { if (!String.IsNullOrEmpty(e.NewTextValue)) SearchBar.ItemsSource = _items.Where(x => x.ToLower().StartsWith(e.NewTextValue.ToLower())).OrderBy(x => x).ToList(); else SearchBar.ItemsSource = _items; }

Where _items is a local reference to full, unfiltered items source.

Contributions

Any contributions are welcome in the form of pull requests.

Issues

Issues can be raised in the Issue section where I'll try to address all of them.