Exemplo n.º 1
0
        internal static void UpdatePicker(this MauiPicker nativePicker, IPicker picker)
        {
            var selectedIndex = picker.SelectedIndex;

            nativePicker.Text = selectedIndex == -1 ? "" : picker.GetItem(selectedIndex);

            var pickerView = nativePicker.UIPickerView;

            pickerView?.ReloadAllComponents();

            if (picker.GetCount() == 0)
            {
                return;
            }

            nativePicker.SetSelectedIndex(picker, selectedIndex);
        }
Exemplo n.º 2
0
        internal static void UpdatePicker(this MauiPicker nativePicker, IPicker picker)
        {
            var selectedIndex = picker.SelectedIndex;
            var items         = picker.Items;

            nativePicker.Text = selectedIndex == -1 || items == null || selectedIndex >= items.Count ? string.Empty : items[selectedIndex];

            var pickerView = nativePicker.UIPickerView;

            pickerView?.ReloadAllComponents();

            if (items == null || items.Count == 0)
            {
                return;
            }

            nativePicker.SetSelectedIndex(picker, selectedIndex);
            nativePicker.SetSelectedItem(picker);
        }
Exemplo n.º 3
0
 public static void UpdateSelectedIndex(this MauiPicker nativePicker, IPicker picker) =>
 nativePicker.SetSelectedIndex(picker, picker.SelectedIndex);