Category / Section
How to add multiple resources to WPF Scheduler?
5 mins read
In the WPF Scheduler, you can add the multiple resources with the ResourceGroupType support.
C#
Create a class ScheduulerViewModel class and add the appointment with the resource details.
public class SchedulerViewModel : NotificationObject { private ScheduleAppointmentCollection events; private ObservableCollection<object> resources; private List<string> eventNames; public SchedulerViewModel() { CreateResources(); CreateResourceAppointments(); } public ScheduleAppointmentCollection Events { get { return events; } set { events = value; RaisePropertyChanged("Events"); } } public ObservableCollection<object> Resources { get { return resources; } set { resources = value; RaisePropertyChanged("Resources"); } } private void CreateResourceAppointments() { Events = new ScheduleAppointmentCollection(); Random randomTime = new Random(); List<Point> randomTimeCollection = this.GettingTimeRanges(); var resurceCollection = this.Resources as ObservableCollection<object>; ------------------------------- ------------------------------- ------------------------------- Events.Add(new ScheduleAppointment() { StartTime = dateTime1, EndTime = dateTime1.AddHours(2), Subject = this.eventNames[randomTime.Next(4)], ResourceIdCollection = new ObservableCollection<object>() { scheduleResource.Id }); } private void CreateResources() { Resources = new ObservableCollection<object>() { new SchedulerResource() { Name = "Sophia", Foreground= new SolidColorBrush(Colors.Black), Background = new SolidColorBrush(Colors.LightSkyBlue), Id = "1000" }, new SchedulerResource() { Name = "Zoey Addison", Foreground= new SolidColorBrush(Colors.Black),Background = new SolidColorBrush(Colors.LightGreen), Id = "1001" }, new SchedulerResource() { Name = "James William",Foreground= new SolidColorBrush(Colors.Black), Background =new SolidColorBrush(Colors.LightPink), Id = "1002" }, }; } }
XAML
Bind the Events and the Resources to the ItemsSource and the ResourceCollection properties.
<Window.DataContext> <local:ResourceViewModel/> </Window.DataContext> <Grid> <syncfusion:SfScheduler x:Name="Schedule" ViewType="{Binding ElementName=schedulerViewTypeComboBox, Path=SelectedValue}" ResourceGroupType="{Binding ElementName=resourceGroupTypeComboBox, Path=SelectedValue,Mode=TwoWay}" ResourceCollection="{Binding Resources}" ItemsSource="{Binding Events}" HeaderHeight="32"> </syncfusion:SfScheduler>
Conclusion
I hope you enjoyed how to add multiple resources to 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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!