Articles in this section
Category / Section

How to add multiple span appointments in the WPF Scheduler?

1 min read

Add the multiple span appointments to the WPF Scheduler by defining the appointment at the same time.

Please refer to the user guide documentation for the spanned Appointment.

C#

Multiple span appointments are added at the same time in the ViewModel.

public class SchedulerViewModel : INotifyPropertyChanged
{
    private ObservableCollection<Meeting> meetings;
    public SchedulerViewModel()
    {
        this.Meetings = new ObservableCollection<Meeting>();
        this.AddAppointments();
    }
    public ObservableCollection<Meeting> Meetings
    {
        get
        {
            return this.meetings;
        }
 
        set
        {
            this.meetings = value;
            this.RaiseOnPropertyChanged("Meetings");
        }
    }
    private void AddAppointments()
    {
        var today = DateTime.Now.Date;
        var random = new Random();
        var meeting = new Meeting();
        meeting.From = today;
        meeting.To = meeting.From.AddDays(2).AddHours(1);
        meeting.EventName = this.currentDayMeetings[random.Next(7)];
        meeting.Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#889e81"));
        this.Meetings.Add(meeting);
 
        var meeting1 = new Meeting();
        meeting1.From = today;
        meeting1.To = meeting1.From.AddDays(1).AddHours(3);
        meeting1.EventName = this.currentDayMeetings[random.Next(7)];
        meeting1.Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#889e81"));
        this.Meetings.Add(meeting1);
    }
}

XAML

Bind the appointments to the Schedule.ItemSource.

<syncfusion:SfScheduler x:Name="Schedule"
                ViewType="Week" 
                ItemsSource="{Binding Meetings}">
    <syncfusion:SfScheduler.AppointmentMapping>
        <syncfusion:AppointmentMapping StartTime="From"
                                EndTime="To"
                                Subject="EventName"
                                AppointmentBackground="Color"
                                />
    </syncfusion:SfScheduler.AppointmentMapping>
</syncfusion:SfScheduler>

View Sample in GitHub

add milti span appointments in the WPF Scheduler



Conclusion
I hope you enjoyed how to add multiple span appointments in the 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