Hi Jesús,
Greetings from Syncfusion.
We have analyzed your requirement. We have achieved your requirement by setting AllowFiltering as False. When we search the item in the input field, the searching item that is placed after the drop-down height moves to the first item.
Please have the sample for your reference,
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SfComboBox_AllowFiltering477894346
Please check the sample if it meets your requirements and let us know if you have any concerns.
Regards,
Suganya Sethuraman.
Hi Suganya,
Thank you for the help, but, unfortunally, there are a few functionalities that doesn't work just like the Winforms ComboBox counterpart, in order to text it:
Please, select any item on your combo, and next, tap again on it, you can see that you have lost the drop down list, and if you want to select another item, you must tap on the "X", that clears the selection, and brings back the list again.
This behaviour is not acceptable at all for any user that needs to do thousands of combo selections every day.
In case anyone needs the complete Winforms functionality for the Xamarin SfCombobox, here is my solution:
1. Follow this link in order to get all the text selected when tapping the combo:
2. Create the SfComboBox this way: (note the combo's declaration is "CustomComboBox", due to previous step)
SfComboBox combobox = new CustomComboBox()
{
StyleId = null,
ShowSuggestionsOnFocus = true,
ShowClearButton = true,
IsEnabled = true,
IsEditableMode = true,
AllowFiltering = false,
EnableSelectionIndicator = true,
SuggestionMode = SuggestionMode.Contains,
ComboBoxMode = ComboBoxMode.Suggest,
NoResultsFoundText = "Lista vacía",
TextHighlightMode = OccurrenceMode.MultipleOccurrence,
HighlightedTextColor = Color.Red,
HighlightedTextFontAttributes = FontAttributes.Bold
};
3. Attach to a certain combo events in order to fool the combo's behaviour, so that it works like the Winforms one (also note that my Combos are inside an InputLayout):
(inputLayout.InputView as SfComboBox).Completed += ComboBox_Completed;
(inputLayout.InputView as SfComboBox).SelectionChanged += ComboBox_SelectionChanged;
(inputLayout.InputView as SfComboBox).DropDownOpen += ComboBox_DropDownOpen;
(inputLayout.InputView as SfComboBox).FocusChanged += ComboBox_FocusChanged;
(inputLayout.InputView as SfComboBox).ValueChanged += ComboBox_ValueChanged;
4. Finally, here are those combo event's definitions:
private void ComboBox_ValueChanged(object sender, Syncfusion.XForms.ComboBox.ValueChangedEventArgs e)
{
(sender as SfComboBox).AllowFiltering = true;
}
private void ComboBox_Completed(object sender, EventArgs e)
{
(sender as SfComboBox).AllowFiltering = false;
}
private void ComboBox_SelectionChanged(object sender, Syncfusion.XForms.ComboBox.SelectionChangedEventArgs e)
{
(sender as SfComboBox).AllowFiltering = false;
}
private void ComboBox_DropDownOpen(object sender, EventArgs e)
{
(sender as SfComboBox).AllowFiltering = false;
}
private void ComboBox_FocusChanged(object sender, FocusChangedEventArgs e)
{
(sender as SfComboBox).AllowFiltering = false;
}
With these changes my Xamarin combos work the same way the Winforms ones, that is:
- When you drop down the list, and having an item selected, this list shows all the items (a Xamarin SfCombobox by default shows only one, the item selected).
- I can now type into the combo and allows me to filter the list (previously it was not possible since there was only one item on the list, the selected one).
- Absolutely no need to tap on the "X" in order to remove the selected item and to select another one.
- When tapping the combo, all the text gets selected making it possible to type something and inmediatly get the list filtered by what you typed (before, and as stated, you gotta tap on the "X".
Best regards.