Articles in this section
Category / Section

How to show time indicator on a specific time when dragging an appointment in WinUI Scheduler (Calendar)

4 mins read

Show the time indicator only on a specific time while dragging and dropping the appointment in the WinUI Scheduler by using the DragDropSetting and the ShowTimeIndicator property in an AppointmentDragOver event.

C#

In the AppointmentDragOver event, the ShowTimeIndicator property is updated based on the dragging time.

private void OnScheduleAppointmentDragOver(object sender, AppointmentDragOverEventArgs e)
{
    if (e.DraggingTime.Minute == 30 || e.DraggingTime.Minute == 00)
    {
        schedule.DragDropSettings.ShowTimeIndicator = true;
    }
    else
        schedule.DragDropSettings.ShowTimeIndicator = false;
}

C#
Create a collection of Events for the Scheduler.

public SchedulerViewModel()
{
    this.Events = new ScheduleAppointmentCollection();
    var scheduleAppointment = new ScheduleAppointment()
    {
        StartTime = DateTime.Now,
        EndTime = DateTime.Now.AddHours(1),
        AppointmentBackground = new SolidColorBrush(Colors.Green),
        Subject = "Conference",
    };
    Events.Add(scheduleAppointment);
}

XAML

Bind the appointments from the view model to a schedule by using the ItemsSource property and set AllowDrop as true.

<Grid>
 <Grid.DataContext>
  <local:SchedulerViewModel/>
 </Grid.DataContext>
    <syncfusion:SfScheduler x:Name="scheduler"
                            ViewType="WorkWeek" 
                            AllowDrop="True"
                            ItemsSource="{Binding Events}"
                            >
    </syncfusion:SfScheduler>
</Grid>

show time indicator on a specific time when dragging an appointment

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