We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to handle appointments for multiple resources in Schedule?

Platform: Xamarin.Android |
Control: SfSchedule

 

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.

C:\Users\indumathi.ravichandr\AppData\Local\Microsoft\Windows\INetCache\Content.Word\Kanban_Android frame_2.png

C:\Users\indumathi.ravichandr\AppData\Local\Microsoft\Windows\INetCache\Content.Word\Kanban_Android frame_2.png

 

You can download the source code for entire demo of handle appointments for multiple resources from here, Sample

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile