Change the text "ALL-DAY"

4 posts, 1 answers
  1. Anders
    Anders avatar
    8 posts
    Member since:
    Feb 2017

    Posted 06 Sep Link to this post

    How do I change the text "ALL-DAY" on the dayview?

    Kind regards,

    Anders

  2. Anders
    Anders avatar
    8 posts
    Member since:
    Feb 2017

    Posted 11 Sep Link to this post

    Bump 😊
  3. Answer
    Nikolay
    Admin
    Nikolay avatar
    15 posts

    Posted 11 Sep Link to this post

    Hello Anders,

    Changing the DayView "ALL-DAY" label text is currently not exposed in Xamarin.Forms. If you would like to see that functionality I encourage you to submit a feature request in our FeedbackPortal.

    However you can achieve that behavior by creating a custom CalendarRenderer where you will have access to the native control and you can change the label text. I'm posting simple implementation of CustomCalendarRenderer that should solve your problem:

    Android implementation:

    public class CustomCalendarRenderer : CalendarRenderer
    {
        public override bool TrySetViewMode(CalendarViewMode view, bool isAnimated)
        {
            if (view == CalendarViewMode.Day)
            {
                Control.DayView.AllDayEventsViewStyle.AllDayText = "MY Text";
            }
     
            return base.TrySetViewMode(view, isAnimated);
        }
    }


    iOS implementation:

    public class CustomCalendarRenderer : CalendarRenderer
    {
        protected override CalendarDelegate CreateCalendarDelegateOverride()
        {
            return new CustomCalendarDelegate();
        }
    }
     
    public class CustomCalendarDelegate : CalendarDelegate
    {
        public override void DidChangedViewModeFrom(TKCalendar calendar, TKCalendarViewMode previousViewMode, TKCalendarViewMode viewMode)
        {
            base.DidChangedViewModeFrom(calendar, previousViewMode, viewMode);
     
            var dayViewPresenter = calendar.Presenter as TKCalendarDayViewPresenter;
            if (dayViewPresenter == null)
            {
                return;
            }
     
            var allDayLabel = dayViewPresenter.DayView.AllDayEventsView.LabelView as UILabel;
            if (allDayLabel != null)
            {
                allDayLabel.Text = "My Text";
            }
        }
    }


    Here are a few links about how to create a custom renderer:

    I hope I've been helpful.

    Regards,
    Nikolay
    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
  4. Anders
    Anders avatar
    8 posts
    Member since:
    Feb 2017

    Posted 11 Sep Link to this post

    Thank you! Just what I was looking for
Back to Top