コード例 #1
0
        public void ShowPicker()
        {
            // get rid of keyboard if another element triggered it.
            Element root = Parent;

            while (root.Parent != null)
            {
                root = root.Parent;
            }
            ResignFirstResponders((RootElement)root);

            // MonoTouch.Dialog CUSTOM: Download custom MonoTouch.Dialog from here to enable hiding picker when other element is selected:
            // https://github.com/crdeutsch/MonoTouch.Dialog
            //if (EntryStarted != null) {
            //	EntryStarted(this, null);
            //}

            // wire up ability to hide picker when other elements are selected.
            if (!wiredStarted)
            {
                foreach (var sect in (root as RootElement))
                {
                    foreach (var e in sect.Elements)
                    {
                        var ee = e as EntryElement;
                        if (ee != null && ee != this)
                        {
                            // MonoTouch.Dialog CUSTOM: Download custom MonoTouch.Dialog from here to enable hiding picker when other element is selected:
                            // https://github.com/crdeutsch/MonoTouch.Dialog
                            //((EntryElement)e).EntryStarted += delegate {
                            //	ComboBox.HidePicker();
                            //};
                        }
                    }
                }
                wiredStarted = true;
            }

            ComboBox.ShowPicker();
            if (Dvc != null && ShowDoneButton)
            {
                if (Dvc.NavigationItem.RightBarButtonItem != doneButton)
                {
                    oldRightBtn = Dvc.NavigationItem.RightBarButtonItem;
                }
                if (doneButton == null)
                {
                    doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Bordered, delegate {
                        ComboBox.HidePicker();
                        Dvc.NavigationItem.RightBarButtonItem = oldRightBtn;
                    });
                }
                Dvc.NavigationItem.RightBarButtonItem = doneButton;
                doneButtonVisible = true;
            }

            if (originalCellBackgroundColor == null)
            {
                originalCellBackgroundColor = cell.BackgroundColor;
                cell.BackgroundColor        = SelectedBackgroundColor;

                originalEntryBackgroundColor = entry.BackgroundColor;
                entry.BackgroundColor        = SelectedBackgroundColor;

                originalCellTextColor    = cell.TextLabel.TextColor;
                cell.TextLabel.TextColor = SelectedTextColor;

                originalEntryTextColor = entry.TextColor;
                entry.TextColor        = SelectedTextColor;
            }

            pickerVisible = true;
        }