protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Labs.Controls.CalendarView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                _view = e.NewElement;

                LayoutInflater inflatorservice =
                    (LayoutInflater)Context.GetSystemService(Android.Content.Context.LayoutInflaterService);
                var containerView =
                    (LinearLayout)inflatorservice.Inflate(Resource.Layout.calendar_picker, null, false);

                _pickerView = containerView.FindViewById <CalendarPickerView>(Resource.Id.calendar_view);
                _pickerView.Init(new DateTime(2014, 6, 1), new DateTime(2014, 6, 30))
                .InMode(CalendarPickerView.SelectionMode.Single);

                _pickerView.OnDateSelected += (s, ef) =>
                {
                    _view.NotifyDateSelected(ef.SelectedDate);
                };

                SetNativeControl(containerView);
            }
        }
Exemple #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Labs.Controls.CalendarView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                _view = e.NewElement;
                LayoutInflater inflatorservice =
                    (LayoutInflater)Context.GetSystemService(Android.Content.Context.LayoutInflaterService);
                _containerView = inflatorservice.Inflate(Resource.Layout.calendar_picker, null);
                _picker        = _containerView.FindViewById <CalendarPickerView>(Resource.Id.calendar_view);
                _picker.Init(Element.MinDate, Element.MaxDate, Element.HighlightedDaysOfWeek);
                _picker.OnDateSelected += (object sender, DateSelectedEventArgs evt) => {
                    ProtectFromEventCycle(() => {
                        Element.NotifyDateSelected(evt.SelectedDate);
                    });
                };
                _picker.OnMonthChanged += (object sender, MonthChangedEventArgs mch) => {
                    SetNavigationArrows();
                    ProtectFromEventCycle(() => {
                        Element.NotifyDisplayedMonthChanged(mch.DisplayedMonth);
                    });
                };
                this.SetDisplayedMonth(Element.DisplayedMonth);
                SetNavigationArrows();
                SetColors();
                SetFonts();
                SetNativeControl((Android.Widget.RelativeLayout)_containerView);
            }
        }