Decorate cells with specif color

2 posts, 0 answers
  1. Fabio
    Fabio avatar
    20 posts
    Member since:
    Apr 2015

    Posted 21 May 2015 Link to this post

    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

  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 27 May 2015 Link to this post

    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
  3. DevCraft banner
Back to Top