Articles in this section

How to show time indicator on a specific time when dragging an appointment in WPF Scheduler?

You can show the popup on specific time when do drag and drop the appointment in WPF SfScheduler by using the ShowTimeIndicator property of DragandDropSettings in a AppointmentDragOver event in WPF Scheduler.

C#

Create a custom class Meeting with mandatory fields From, To, EventName and color.

public class Meeting : INotifyPropertyChanged
{
    private string eventName;
    private bool allDay;
    private Brush color;
    private DateTime to;
    private DateTime from;
}  

C#

Create a ViewModel class and add the appointment details.

public class SchedulerViewModel : INotifyPropertyChanged
{
    private ObservableCollection<Meeting> meetings;
    
    public SchedulerViewModel()
    {
        Meetings = new ObservableCollection<Meeting>();
        Meeting meeting = new Meeting();
        meeting.From = DateTime.Today.AddHours(13);
        meeting.To = meeting.From.AddHours(1);
        meeting.EventName = "Anniversary";
        meeting.AllDay = false;
        meeting.Color = Brushes.Green;
        Meetings.Add(meeting);
    }
}

XAML

Bind the appointments to a schedule using the Scheduler.ItemsSource property and enable the appointment drag and drop by setting the AppointmentEditFlag as DragDrop

<Window.DataContext>
<local:SchedulerViewModel/>
</Window.DataContext>
<Grid>
<syncfusion:SfScheduler 
        x:Name="Schedule" 
        ViewType="Week"
        ItemsSource="{Binding Meetings}"
        AppointmentEditFlag="DragDrop">
    <syncfusion:SfScheduler.AppointmentMapping>
        <syncfusion:AppointmentMapping
                StartTime="From"
                EndTime="To"
                Subject="EventName"
                AppointmentBackground="Color"
                IsAllDay="AllDay" >
        </syncfusion:AppointmentMapping>
    </syncfusion:SfScheduler.AppointmentMapping>
    <interactivity:Interaction.Behaviors>
        <local:SchedulerBehavior/>
    </interactivity:Interaction.Behaviors>
</syncfusion:SfScheduler>
</Grid>

C#

ShowTimeIndicator property updated in the AppointmentDragOver event based on the dragging time.

public class SchedulerBehavior : Behavior<SfScheduler>
{
    SfScheduler scheduler;
    protected override void OnAttached()
    {
        base.OnAttached();
        scheduler = this.AssociatedObject;
        this.AssociatedObject.AppointmentDragOver += Scheduler_AppointmentDragOver;
    }
    private void Scheduler_AppointmentDragOver(object sender, AppointmentDragOverEventArgs e)
    {
        if (e.DraggingTime.Minute == 30 || e.DraggingTime.Minute == 00)
        {
            this.AssociatedObject.DragDropSettings.ShowTimeIndicator = true;
        }
        else
            this.AssociatedObject.DragDropSettings.ShowTimeIndicator = false;
    }
    protected override void OnDetaching()
    {
        base.OnDetaching();
        this.AssociatedObject.AppointmentDragOver -= Scheduler_AppointmentDragOver;
        this.scheduler = null;
    }
}

View sample in GitHub

Demo image for TimeIndicator

Conclusion

I hope you enjoyed learning about how to show time indicator on a specific time when dragging an appointment in WPF Scheduler.

You can refer to our WPF Scheduler feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied