How to customize RadCalendar month title in iOS?

3 posts, 0 answers
  1. Dev
    Dev avatar
    9 posts
    Member since:
    Apr 2018

    Posted 02 May Link to this post

    I've created a custom calendar delegate for iOS as described here (https://docs.telerik.com/devtools/xamarin/controls/calendar/styling/custom-renderers/calendar-customrenderers-ios), and I'm trying to use it customize the calendar's month title cell. In my delegate, I have:

    public override void UpdateVisualsForCell(TKCalendar calendar, TKCalendarCell cell)
    {
        base.UpdateVisualsForCell(calendar, cell);
     
        switch (cell)
        {
           case TKCalendarMonthTitleCell monthTitleCell:
                FormatMonthTitleCell(monthTitleCell);
                break;
        }
    }
     
    private void FormatMonthTitleCell(TKCalendarMonthTitleCell monthTitleCell)
    {
       monthTitleCell.Label.Text = "custom title";
    }

     

    I can see that the label's text is indeed changed when debugging, however, the title still displays as "[month] [year]". Is there something else that I need to be setting or hooking into in order to change the title?

  2. Ves
    Admin
    Ves avatar
    2927 posts

    Posted 07 May Link to this post

    Hi,

    You can use a custom cell as shown in this help topic -- Calendar Customizations. Basically, you need to override ViewForCellOfKind like this:

    public override TKCalendarCell ViewForCellOfKind(TKCalendar calendar, TKCalendarCellType cellType)
            {
                if (cellType == TKCalendarCellType.Title)
                {
                    CustomCell cell = new CustomCell();
                    return cell;
                }
     
                return base.ViewForCellOfKind(calendar, cellType);
            }

    and then provide your custom cell:

    public class CustomCell : TKCalendarTitleCell
        {
            public CustomCell()
            {
            }
     
            public override void UpdateVisuals()
            {
                base.UpdateVisuals();
                this.Label.Text = "custom label";
            }
        }


    Best regards,
    Ves
    Progress 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. Dev
    Dev avatar
    9 posts
    Member since:
    Apr 2018

    Posted 11 May in reply to Ves Link to this post

    Perfect. Works beautifully. Thanks.
Back to Top