Selected date Stroke Alligment

4 posts, 1 answers
  1. Adam
    Adam avatar
    24 posts
    Member since:
    Aug 2017

    Posted 12 Aug Link to this post

    Hello! Is there a way to align the stroke of a selected cell? I have problems displaying the selected cell correctly. (Please see attachment)

     
  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    498 posts

    Posted 16 Aug Link to this post

    Hi Adam,

    You can create a custom renderer for the iOS platform and work with the Style property of the TKCalendarDayCell to update its visual appearance.

    For example:

    Create the custom renderer:

     
     class CustomCalendarRenderer : CalendarRenderer
        {
            protected override void OnElementChanged(ElementChangedEventArgs<RadCalendar> e)
            {
                base.OnElementChanged(e);
                this.Control.Delegate = new CalendarDelegate();
            }
        }

    The definition of the Custom Delegate:
    class CalendarDelegate : TKCalendarDelegate
       {
           public override TKCalendarCell ViewForCellOfKind(TKCalendar calendar, TKCalendarCellType cellType)
           {
               if (cellType == TKCalendarCellType.Day)
               {
                   return new CustomCell();
               }
               return null;
           }
       }

    And the CustomCell where you can work with the Style property:

    public class CustomCell : TKCalendarDayCell
       {
           public override void UpdateVisuals()
           {
               this.Style.TextColor = UIColor.Purple;
               this.Style.TextAlignment = TKCalendarCellAlignment.Top;
               this.Style.Shape = null;
     
               base.UpdateVisuals();
           }
       }


    Regards,
    Stefan Nenchev
    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. Adam
    Adam avatar
    24 posts
    Member since:
    Aug 2017

    Posted 16 Aug Link to this post

    Hello @Stefan What if I want the Shape to be also aligned to the Top?
  4. Answer
    Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    498 posts

    Posted 21 Aug Link to this post

    Hello Adam,

    Unfortunately, no easy way to achieve that, however, you can add images as the background of the current/selected cells and imitate the stroke. Please have a look at the attached example which is based on the CalendarCustomization example from the iOS Examples application which can be found in your local Telerik UI for Xamarin Installation. The stroke I have created is far from perfect, however, you should be able to modify the image so that it fits your requirements. You can consider setting it only for the selected cell as well.

    Have a great week.

    Regards,
    Stefan Nenchev
    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
Back to Top