async void Handle_Tapped(object sender, System.EventArgs e)
        {
            if (OwnerPage == null)
            {
                System.Diagnostics.Debug.WriteLine("MyPicker: OwnerPage is null");
                return;
            }
            if (busy)
            {
                return;
            }
            busy = true;
            List <string> buttons = new List <string>();

            if (ItemsSource != null)
            {
                foreach (var item in ItemsSource)
                {
                    if (item != null)
                    {
                        buttons.Add(item.ToString());
                    }
                    else
                    {
                        buttons.Add("无");
                    }
                }
            }
            var result = await OwnerPage.DisplayActionSheet(Title, null, null, buttons.ToArray());

            busy = false;
            if (result == null)
            {
                return;
            }
            int selectedIndex = buttons.IndexOf(result);
            int index         = 0;

            foreach (var item in ItemsSource)
            {
                if (index == selectedIndex)
                {
                    SelectedItem = item;
                    break;
                }
                index++;
            }
            HandleSelectedItemChanged();
        }
Exemple #2
0
        async void Handle_Tapped(object sender, System.EventArgs e)
        {
            if (OwnerPage == null)
            {
                System.Diagnostics.Debug.WriteLine("MyPicker: OwnerPage is null");
                return;
            }
            if (busy)
            {
                return;
            }
            busy = true;
            List <string> buttons = new List <string>();

            if (ItemsSource != null)
            {
                foreach (var item in ItemsSource)
                {
                    if (item != null)
                    {
                        buttons.Add(item.ToString());
                    }
                    else
                    {
                        buttons.Add("item is null");
                    }
                }
            }
            var result = await OwnerPage.DisplayActionSheet(Title, null, null, buttons.ToArray());

            busy = false;
            if (result == null)
            {
                return;
            }
            SelectedItem = result;
            UpdateLabel();
        }