Change default appointment duration

4 posts, 1 answers
  1. Andrey
    Andrey avatar
    2 posts
    Member since:
    Oct 2012

    Posted 26 Nov 2012 Link to this post

    Hello!

    In my application I have a ListBox and RadScheduleView. I can create a new appointment by drag'n'drop from ListBox. Default duration for new appointment is 1 hour.

    I have a  ScheduleViewDragDropBehavior class and I tried to set End property for new appoinment here, but Start and End properties are equal 1000/01/01. 

    public class ScheduleViewDragDropBehavior : Telerik.Windows.Controls.ScheduleViewDragDropBehavior
        {
            public override IEnumerable<IOccurrence> ConvertDraggedData(object data)
            {
                if (DataObjectHelper.GetDataPresent(data, typeof(Campaign), false))
                {
                    var campaigns = DataObjectHelper.GetData(data, typeof(Campaign), true) as IEnumerable;
                    if (campaigns != null)
                    {
                        var appCollection = campaigns.OfType<Campaign>().Select(c => new AppointmentCampaign { Subject = c.Name, Campaign = c, Category = new Category("", c.Brush) });
     
                        return appCollection;
                    }
                }
                return base.ConvertDraggedData(data);
            }
        }
     

    So, how can I change default duration?

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 29 Nov 2012 Link to this post

    Hello Andrey,

    You should override CanDrop method in your ScheduleViewDragDropBehavior and change the End time of the destination slot. Here is an example:

    public override bool CanDrop(Telerik.Windows.Controls.DragDropState state)
    {
        var destSlot = state.DestinationSlots.First();
        destSlot.End = destSlot.Start.AddHours(2);
        return base.CanDrop(state);
    }

    Greetings,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 29 Nov 2012 Link to this post

    Hi Andrey,

    Actually it should be like this:

    public override bool CanDrop(Telerik.Windows.Controls.DragDropState state)
    {
        if (state.DestinationAppointmentsSource != state.SourceAppointmentsSource)
        {
            var destSlot = state.DestinationSlots.First();
            destSlot.End = destSlot.Start.AddHours(2);
        }
        return base.CanDrop(state);
    }

    The condition is needed to distinguish whether the appointment is dragged from outside the ScheduleView.

    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Andrey
    Andrey avatar
    2 posts
    Member since:
    Oct 2012

    Posted 29 Nov 2012 Link to this post

    It works fine! Thank you!
Back to Top