Beispiel #1
0
        public PickerView()
        {
            _picker = new BlankPicker
            {
                BackgroundColor = Color.Transparent
            };
            Input = _picker;
            _picker.SetBinding(Entry.TextProperty,
                               new Binding(nameof(EntryText))
            {
                Source = this, Mode = BindingMode.OneWayToSource
            });
            _picker.SetBinding(Entry.TextProperty,
                               new Binding(nameof(EntryText))
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            _picker.SetBinding(Entry.FontAttributesProperty,
                               new Binding(nameof(EntryFontAttributes))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Entry.FontFamilyProperty,
                               new Binding(nameof(EntryFontFamily))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Entry.FontSizeProperty,
                               new Binding(nameof(EntryFontSize))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Entry.PlaceholderProperty,
                               new Binding(nameof(EntryPlaceholder))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Entry.PlaceholderColorProperty,
                               new Binding(nameof(EntryPlaceholderColor))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Entry.HorizontalTextAlignmentProperty,
                               new Binding(nameof(EntryHorizontalTextAlignment))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Entry.TextColorProperty,
                               new Binding(nameof(EntryTextColor))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(HeightRequestProperty,
                               new Binding(nameof(EntryHeightRequest))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(MarginProperty,
                               new Binding(nameof(EntryMargin))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            //_picker.SetBinding(BlankPicker.ItemsSourceProperty,
            //    new Binding(nameof(ItemsSource)) {Source = this, Mode = BindingMode.OneWay});
            //_picker.SetBinding(BlankPicker.SelectedIndexProperty,
            //    new Binding(nameof(SelectedIndex)) {Source = this, Mode = BindingMode.TwoWay});
            //_picker.SetBinding(BlankPicker.SelectedItemProperty,
            //    new Binding(nameof(SelectedItem)) {Source = this, Mode = BindingMode.TwoWay});
            _picker.SetBinding(BlankPicker.TitleProperty,
                               new Binding(nameof(Title))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            _picker.SetBinding(IsEnabledProperty,
                               new Binding(nameof(IsReadOnly))
            {
                Source = this, Mode = BindingMode.OneWay, Converter = new InverseBooleanConverter()
            });
            _picker.SetBinding(InputTransparentProperty,
                               new Binding(nameof(IsReadOnly))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(HeightRequestProperty,
                               new Binding(nameof(EntryHeightRequest))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            //Todo For Xamarin.Forms 4.0
            //_picker.SetBinding(Picker.TitleColorProperty,
            //new Binding(nameof(TitleColor)) { Source = this, Mode = BindingMode.OneWay });

            _picker.SetBinding(BlankPicker.DoneButtonTextProperty,
                               new Binding(nameof(DoneButtonText))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(BlankPicker.CancelButtonTextProperty,
                               new Binding(nameof(CancelButtonText))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(BlankPicker.UpdateModeProperty,
                               new Binding(nameof(UpdateMode))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            _picker.Focused              += FocusEntry;
            _picker.Unfocused            += UnfocusEntry;
            _picker.SelectedIndexChanged += IndexChanged;
            _picker.TextChanged          += SendEntryTextChanged;

            FloatingLabelWithoutAnimation();

            Children.Add(_picker, 2, 3, 1, 2);
        }
        public PickerView()
        {
            _picker = new BlankPicker
            {
                BackgroundColor = Color.Transparent,
            };
            _picker.SetBinding(Picker.FontAttributesProperty,
                               new Binding(nameof(EntryFontAttributes))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Picker.FontFamilyProperty,
                               new Binding(nameof(EntryFontFamily))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Picker.FontSizeProperty,
                               new Binding(nameof(EntryFontSize))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(BlankPicker.PlaceholderProperty,
                               new Binding(nameof(EntryPlaceholder))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(BlankPicker.PlaceholderColorProperty,
                               new Binding(nameof(EntryPlaceholderColor))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(BlankPicker.HorizontalTextAlignmentProperty,
                               new Binding(nameof(EntryHorizontalTextAlignment))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Picker.TextColorProperty,
                               new Binding(nameof(EntryTextColor))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(HeightRequestProperty,
                               new Binding(nameof(EntryHeightRequest))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            _picker.SetBinding(Picker.ItemsSourceProperty,
                               new Binding(nameof(ItemsSource))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Picker.SelectedIndexProperty,
                               new Binding(nameof(SelectedIndex))
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            _picker.SetBinding(Picker.SelectedItemProperty,
                               new Binding(nameof(SelectedItem))
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            _picker.SetBinding(Picker.TitleProperty,
                               new Binding(nameof(Title))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            //Todo For Xamarin.Forms 4.0
            //_picker.SetBinding(Picker.TitleColorProperty,
            //new Binding(nameof(TitleColor)) { Source = this, Mode = BindingMode.OneWay });

            _picker.SetBinding(BlankPicker.DoneButtonTextProperty,
                               new Binding(nameof(DoneButtonText))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(BlankPicker.CancelButtonTextProperty,
                               new Binding(nameof(CancelButtonText))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            _pFrame = new Frame
            {
                Padding         = 0,
                HasShadow       = false,
                BackgroundColor = Color.Transparent,
                Content         = _picker
            };
            _pFrame.SetBinding(IsEnabledProperty,
                               new Binding(nameof(IsReadOnly))
            {
                Source = this, Mode = BindingMode.OneWay, Converter = new InverseBooleanConverter()
            });
            _pFrame.SetBinding(InputTransparentProperty,
                               new Binding(nameof(IsReadOnly))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _pFrame.SetBinding(HeightRequestProperty,
                               new Binding(nameof(EntryHeightRequest))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            TextAlignmentCommand = new Command(() => TextAlignmentChanged());

            _picker.Focused              += FocusEntry;
            _picker.Unfocused            += UnfocusEntry;
            _picker.SelectedIndexChanged += IndexChanged;

            _picker.DoneClicked   += (sender, e) => DoneClicked?.Invoke(this, e);
            _picker.CancelClicked += (sender, e) => CancelClicked?.Invoke(this, e);

            Children.Add(_pFrame, 2, 3, 1, 2);
        }