XAM-Consulting / FreshEssentials

FreshEssentials for Xamarin.Forms has ONLY the most common extensions you need for Xamarin.Forms
Apache License 2.0
107 stars 30 forks source link

BindablePicker.cs question #28

Open michaelb4 opened 7 years ago

michaelb4 commented 7 years ago

In the OnSelectedItemChanged event, should the SelectedIndex be set to -1 when SelectedItem == null?

private static void OnSelectedItemChanged(BindableObject bindable, object oldValue, object newValue) { BindablePicker picker = (BindablePicker)bindable; picker.SelectedItem = newValue; if (picker.ItemsSource != null && picker.SelectedItem != null) { int count = 0; foreach (object obj in picker.ItemsSource) { if (obj == picker.SelectedItem) { picker.SelectedIndex = count; break; } count++; } } }

For instance: else picker.SelectedIndex = -1;

Thank you for your consideration.