Articles in this section
Category / Section

How to load appointments on demand in WPF Scheduler?

1 min read

The WPF scheduler supports load appointments on-demand with a loading indicator.

C#

Use QueryAppointments to load the appointments in on-demand for the visible date range. Loading appointments in on-demand improves the loading performance when you have appointments ranging for multiple years. Start and stop the loading indicator animation before and after the appointments are loaded using the ShowBusyIndicator.

private async void OnScheduleQueryAppointments(object sender, QueryAppointmentsEventArgs e)
{
    schedule.ShowBusyIndicator = true;
    await Task.Delay(1000);
    schedule.ItemsSource = this.GenerateSchedulerAppointments(e.VisibleDateRange);
    schedule.ShowBusyIndicator = false;
}
 
private IEnumerable GenerateSchedulerAppointments(DateRange dateRange)
{
    Random random = new Random();
    int daysCount = (dateRange.ActualEndDate - dateRange.ActualStartDate).Days;
    var appointments = new ObservableCollection<ScheduleAppointment>();
 
    for (int i = 0; i < 50; i++)
    {
        var startTime = dateRange.ActualStartDate.AddDays(random.Next(0, daysCount + 1)).AddHours(random.Next(0, 24));
        appointments.Add(new ScheduleAppointment
        {
            StartTime = startTime,
            EndTime = startTime.AddHours(1),
            Subject = subjectCollection[random.Next(0, subjectCollection.Count)],
            AppointmentBackground = brush[random.Next(0, brush.Count)],
        });
    }
    return appointments;
}

View sample in GitHub

Loading the appointments on demand.


Conclusion
I hope you enjoyed how to load appointments on demand in WPF Scheduler.
You can refer to our WPF Schedule feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF Schedule example to understand how to create and manipulate data.
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)
Please  to leave a comment
Access denied
Access denied