This is a migrated thread and some comments may be shown as answers.

Decorate cells with specif color

1 Answer 21 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Fabio
Top achievements
Rank 1
Fabio asked on 21 May 2015, 11:16 PM

Hello

I want to achieve something similar to this:

 http://s18.postimg.org/66xq6aemh/Screenshot_2015_05_21_18_08_58.png

I am using the UI fo Xamarin forms but I am using a custom renderer, in the Android version I have extended the CalendarDayCell:

Here is my custom renderer:

public class CustomCalendarRenderer : ViewRenderer<CustomCalendar, TKCalendar>
    {
        CustomCalendar calendar;
        TKCalendar calendarView;
 
        protected override void OnElementChanged(ElementChangedEventArgs<CustomCalendar> e)
        {
 
            try
            {
                base.OnElementChanged(e);
 
                if (e.NewElement == null)
                    return;
 
                calendar = e.NewElement;
                calendarView = new TKCalendar(this.Bounds);
                AppointmentCalendarDelegate calendarDelegate;
                calendarView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                calendarDelegate = new AppointmentCalendarDelegate();
                calendarView.Delegate = calendarDelegate;
                calendarDelegate.SelectionChanged += calendarDelegate_SelectionChanged;
                //this.calendarView.MinDate = this.calendar.MinDate.ToNSDate();
                //this.calendarView.MaxDate = this.calendar.MaxDate.ToNSDate();
 
                calendarView.Locale = new NSLocale("es_MX");
                calendarView.Update(false);
 
                if (calendar.Type == 2)
                {
                    calendarView.ViewMode = TKCalendarViewMode.Year;
                }
 
                SetNativeControl(this.calendarView);
            }
 
 
            catch
            {
                //Ignored
            }
        }
 
        void calendarDelegate_SelectionChanged(object sender, ValueChangedEventArgs<object> e)
        {
            this.calendar.SelectedDate = (DateTime?)e.NewValue;
        }
    }

 Please let me know your comments/suggestions

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 27 May 2015, 05:35 AM
Hi Fabio,

You can actually inherit directly from CalendarRenderer and take advantage of all the features already implemented. You will only need to take care of the customizations. Please, find attached a small example.


Regards,
Ves
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Calendar
Asked by
Fabio
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or