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.Forms |
Control: SfSchedule


In SfSchedule, you can enable resources and add appointments under it in sample level.



     SfSchedule sfschedule;
     ScheduleAppointmentCollection appointmentCollection;
     WeekViewSettings weekviewsettings;
    public  TestClass()
        sfschedule=new SfSchedule();
        sfschedule.ScheduleView = ScheduleView.WeekView;
        sfschedule.VerticalOptions = LayoutOptions.FillAndExpand;
        appointmentCollection = new ScheduleAppointmentCollection();
        weekviewsettings = new WeekViewSettings();
        weekviewsettings.ShowAllDay = true;
        sfschedule.WeekViewSettings = weekviewsettings;
        Switch resource1 = new Switch();
        resource1.BackgroundColor = Color.Red;
        Label resource1_label = new Label();
        resource1_label.Text="Dr. Joseph (nephrologist)";
        resource1_label.TextColor = Color.Black;
        resource1_label.BackgroundColor = Color.Red;
        resource1.IsToggled = false;
        resource1.Toggled += resource1_Toggled;
        StackLayout resource1_layout = new StackLayout();
        resource1_layout.Orientation = StackOrientation.Horizontal;
        Switch resource2 = new Switch();
        resource2.BackgroundColor = Color.Blue;
        Label resource2_label = new Label();
        resource2_label.Text = "Dr. Stephen (diabetoligist)";
        resource2_label.TextColor = Color.Black;
        resource2_label.BackgroundColor = Color.Blue;
        resource2.IsToggled = false;
        resource2.Toggled += resource2_Toggled;
        StackLayout resource2_layout = new StackLayout();
        resource2_layout.Orientation = StackOrientation.Horizontal;
        StackLayout layout = new StackLayout();
        layout.Orientation = StackOrientation.Vertical;
        layout.HorizontalOptions = LayoutOptions.FillAndExpand;
        StackLayout schedule_layout = new StackLayout();
        schedule_layout.VerticalOptions = LayoutOptions.FillAndExpand;
        StackLayout mainlayout = new StackLayout();
        mainlayout.Orientation = StackOrientation.Vertical;
        this.Content= mainlayout;


Add appointments accordingly to the respective resources. Here, two switches are used such that appointment collection is set for each switch. When the switch is toggled, respective schedule’s appointment is displayed in the view and when it is toggled back, appointment collection gets cleared. Thus, appointments are handled using switch in this sample.



   void resource1_Toggled(object sender, ToggledEventArgs e)
        if (e.Value)
            ScheduleAppointment resource1_appointment = new ScheduleAppointment();
            DateTime currentDate = DateTime.Now;
            DateTime startTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 10, 0, 0);
            DateTime endTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, 12, 0, 0);
            resource1_appointment.StartTime = startTime;
            resource1_appointment.EndTime = endTime;
            resource1_appointment.Color = Color.Red;
            resource1_appointment.Subject = "Kidney Stones removal";
            sfschedule.DataSource = appointmentCollection;
    void resource2_Toggled(object sender, ToggledEventArgs e)
        if (e.Value)
            ScheduleAppointment resource2_appointment = new ScheduleAppointment();
            DateTime currentDate1 = DateTime.Now.AddDays(2);
            DateTime startTime1 = new DateTime(currentDate1.Year, currentDate1.Month, currentDate1.Day, 9, 0, 0);
            DateTime endTime1 = new DateTime(currentDate1.Year, currentDate1.Month, currentDate1.Day, 12, 0, 0);
            resource2_appointment.StartTime = startTime1;
            resource2_appointment.EndTime = endTime1;
            resource2_appointment.Color = Color.Blue;
            resource2_appointment.Subject = "Blood Sugar Test";
            sfschedule.DataSource = appointmentCollection;


The following screenshot displays the resource with appointment in Week View.





You can download the entire source code of this demo for Xamarin.Forms from  
here, ScheduleResource .



2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
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