How to handle appointments for multiple resources in Xamarin.Android Schedule?
In SfSchedule control, you can enable resources and add Appointment Resources under it. Here Resource is used to add additional information about the appointments.
For enabling Resource in SfSchedule
Create Xamarin.Android application and add SfSchedule control to it.
// Adding Schedule Control SfSchedule schedule; schedule = new SfSchedule (this); schedule.Locale = new Locale("en"); schedule.WeekViewSettings.WorkStartHour = 9; schedule.ScheduleView = ScheduleView.DayView; // Appointment Collections. ScheduleAppointmentCollection appointmentsCollection1 = new ScheduleAppointmentCollection(); ScheduleAppointmentCollection appointmentsCollection = new ScheduleAppointmentCollection(); // Move to Date Calendar moveToDate = Calendar.Instance; moveToDate.Set(2017, 8, 2, 9, 0, 0); schedule.MoveToDate = moveToDate;
Now, add CheckBox as resource as follows.
// Adding CheckBox Resources CheckBox resource1 = new CheckBox(this); resource1.SetText("Dr. Joseph (nephrologist)",TextView.BufferType.Normal); resource1.SetBackgroundColor(Color.Red); resource1.Checked = false; resource1.CheckedChange += Resource1_CheckedChange; CheckBox resource2 = new CheckBox(this); resource2.SetText("Dr. Rosario (Endocrinologist)", TextView.BufferType.Normal); resource2.SetBackgroundColor(Color.Green); resource2.Checked = false; resource2.CheckedChange += Resource2_CheckedChange;
Now add the appointments Collection in the Schedule under the specific CheckBox resource by Adding the AppointmentCollection property of it, as follows.
// Adding Appointment Collection private void Resource1_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e) { if (e.IsChecked) { ScheduleAppointment scheduleAppointment1 = new ScheduleAppointment(); Calendar currentDate = Calendar.Instance; Calendar startTime = (Calendar)currentDate.Clone(); resource2.Checked=false; //setting start time for the event startTime.Set(2017,8,2,09,0); Calendar endTime = (Calendar)currentDate.Clone(); //setting end time for the event endTime.Set(2017, 8, 2, 12, 0); scheduleAppointment1.Color = Color.Red; scheduleAppointment1.Subject = "Kidney Stones removal"; scheduleAppointment1.StartTime = startTime; scheduleAppointment1.EndTime = endTime; appointmentsCollection1.Add(scheduleAppointment1); schedule.ItemsSource=appointmentsCollection1; } else { appointmentsCollection1.Clear(); } } private void Resource2_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e) { if (e.IsChecked) { ScheduleAppointment scheduleAppointment = new ScheduleAppointment(); Calendar currentDate = Calendar.Instance; Calendar startTime = (Calendar)currentDate.Clone(); resource1.Checked=false; //setting start time for the event startTime.Set(2017,8,1,10,0); Calendar endTime = (Calendar)currentDate.Clone(); //setting end time for the event endTime.Set(2017, 8, 1, 13, 0); scheduleAppointment.Color = Color.Green; scheduleAppointment.Subject = "Blood sugar test"; scheduleAppointment.StartTime = startTime; scheduleAppointment.EndTime = endTime; appointmentsCollection.Add(scheduleAppointment); schedule.ItemsSource=appointmentsCollection; } else { appointmentsCollection.Clear(); } }
The following screenshot displays the resource with appointment in Week View.
You can download the source code for entire demo of handle appointments for multiple resources from here, Sample
Conclusion
I hope you enjoyed learning about how to handle appointments for multiple resources in Xamarin.Android Schedule.
You can refer to our Xamarin.Android 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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!