MonthChanged Event?

3 posts, 0 answers
  1. Matt
    Matt avatar
    17 posts
    Member since:
    Jan 2013

    Posted 18 Jan 2015 Link to this post

    Is there an event that I can tie into when the month is changed? I would like to select the first date of the new month so that any detailed appointment data below is not still from a previous selection.

    I've tried subscribing to SelectionChanged as the example shows, but that is not triggered unless a new date is actually tapped.

    Thanks.
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 22 Jan 2015 Link to this post

    Hi Matt,

    You can take advantage of the commands in RadCalendar. Specifically, MoveToPreviousView and MoveToNextView should do the trick for your. Here is a sample implementation for MoveToPreviousView:

    public class CustomMoveToPreviousViewCommand : CalendarCommand
    {
        public CustomMoveToPreviousViewCommand()
        {
            this.Id = CommandId.MoveToPreviousView;
        }
     
        public override bool CanExecute(object parameter)
        {
            return true;
        }
     
        public override void Execute(object parameter)
        {
            var context = parameter as CalendarViewChangeContext;
            this.Owner.CommandService.ExecuteDefaultCommand(this.Id, parameter);
     
            // Check this.Owner.DisplayDate here
        }
    }

    The value of this.Owner.DisplayDate will reflect the navigation and will hold a date from the month being shown.

    Best regards,
    Ves
    Telerik

  3. Matt
    Matt avatar
    17 posts
    Member since:
    Jan 2013

    Posted 25 Jan 2015 in reply to Ves Link to this post

    Works great, thank you!
Back to Top