Easily Allocate Resources with the Resource View in WPF Scheduler
Tags: wpf, csharp, dotnet, productivity
Published: 2020-11-10 11:12:43

---
title: Easily Allocate Resources with the Resource View in WPF Scheduler
published: true
date: 2020-11-06 10:00:25 UTC
tags: WPF, csharp, dotnet, productivity
canonical_url: https://www.syncfusion.com/blogs/post/easily-allocate-resources-with-the-resource-view-in-wpf-scheduler.aspx
cover_image: https://www.syncfusion.com/blogs/wp-content/uploads/2020/10/Easily-Allocate-Resources-with-the-Resource-View-in-WPF-Scheduler-672x372.png
---

**“Human resource isn’t a thing we do. It’s the thing that runs the business.”**

– **Steve Wynn**

In strategic planning, resource allocation is a key factor for using available resources, especially in the near term, to achieve business goals. It is so important to get a clear picture of the amount of work that must be done. It also helps us to schedule ahead and have insight into a team’s progress, allowing us to allocate the right amount of time to everyone on the team.

By using the resource view in the Syncfusion WPF Scheduler control, you can easily manage and allocate resources in a calendar view by controlling the project tasks, time sheets, and employee availability.

In this blog, I will explain how easy it is to manage and allocate resources using the key features of the [Syncfusion WPF Scheduler control](https://www.syncfusion.com/wpf-ui-controls/scheduler). If you are new to our Scheduler control, please read the getting started article in the Scheduler [documentation](https://help.syncfusion.com/wpf/scheduler/getting-started) before proceeding.

Let’s get started!

## Scheduler resource view

It’s very simple to add a resource view to the Scheduler control. You can create and bind resources to the Scheduler control using the [ResourceCollection](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_ResourceCollection) API in the Scheduler class with the required fields like [Id](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SchedulerResource.html#Syncfusion_UI_Xaml_Scheduler_SchedulerResource_Id) and [Name](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SchedulerResource.html#Syncfusion_UI_Xaml_Scheduler_SchedulerResource_Name), and optional fields like [Background](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SchedulerResource.html#Syncfusion_UI_Xaml_Scheduler_SchedulerResource_Background) and [Foreground](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SchedulerResource.html#Syncfusion_UI_Xaml_Scheduler_SchedulerResource_Foreground) and so on.  
Refer to the following code example.

```html
<syncfusion:SfScheduler ViewType="WorkWeek">
  <syncfusion:SfScheduler.ResourceCollection>
      <syncfusion:SfScheduler.ResourceCollection>
          <local:SchedulerResourceCollection>
              // Creates instance of scheduler resource.
              <syncfusion:SchedulerResource 
                  Name="Sophia" 
                  Id="1" 
                  Foreground="White" 
                  Background="#9d65c9" />
          </local:SchedulerResourceCollection>
   </syncfusion:SfScheduler.ResourceCollection>            
</syncfusion:SfScheduler>

```

**Note:** Since **ResourceCollection** is of IEnumerable type, we have maintained a local class **SchedulerResourceCollection** , which is derived from the **ObservableCollection<Object>** to add the resources in XAML code directly.

## **Associating resources with appointments**

You can associate the resources with appointments by assigning the **Id** of the respective resources in the [ResourceIdCollection](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.ScheduleAppointment.html#Syncfusion_UI_Xaml_Scheduler_ScheduleAppointment_ResourceIdCollection) API of the [ScheduleAppointment](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.ScheduleAppointment.html) class like in the following code example.

```csharp
// Creates instance of scheduler appointment.
ScheduleAppointment appointment = new ScheduleAppointment();
appointment.Subject = "Knowledge share";
appointment.StartTime = DateTime.Now.Date.AddDays(1).AddHours(11);
appointment.EndTime = DateTime.Now.Date.AddDays(1).AddHours(13);
appointment.AppointmentBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9d65c9"));

 // Allocates the Scheduler resource iD for this appointment.
 appointment.ResourceIdCollection = new ObservableCollection<object>() { "1" };

```

![Associating Resources with Appointments](https://www.syncfusion.com/blogs/wp-content/uploads/2020/10/Associating-Resources-with-Appointments.png)<figcaption>Associating Resources with Appointments</figcaption>

## Scheduler resource grouping

The Scheduler resource view provides support to specify whether the dates should be grouped under resources or resources should be grouped under dates in the day view (or week or workweek views) in by column.

**Note:** In the timeline view, resources are arranged in rows and dates are arranged in columns, thus grouping can’t be enabled directly in it.

By using the [ResourceGroupType](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_ResourceGroupType) API in the [Scheduler](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html) class, you can allocate tasks to employees either by setting the **ResourceGroupType** as **Resource** or by setting the **ResourceGroupType** as **Date**.

Refer to the following code example.

```html
// Sets resource group type as Resource.
<syncfusion:SfScheduler ViewType="WorkWeek" ResourceGroupType="Resource" >
</syncfusion:SfScheduler>
```

![Group by Resource](https://www.syncfusion.com/blogs/wp-content/uploads/2020/10/Group-by-Resource.png)<figcaption>Group by Resource</figcaption>

![Group by Date](https://www.syncfusion.com/blogs/wp-content/uploads/2020/10/Group-by-Date.png)<figcaption>Group by Date</figcaption>

## **Resource sharing**

Sometimes multiple resources are required to accomplish a task. You are free to assign as many _resources_ as you wish to a _task_ by assigning the Id of the respective resources in the **ResourceIdCollection**. Any edit to the shared event will be reflected in the associated individual resources.

![Resource Sharing](https://www.syncfusion.com/blogs/wp-content/uploads/2020/10/Resource-Sharing.png)<figcaption>Resource Sharing</figcaption>

## **Data binding**

The resource view provides MVVM ([model- view-viewmodel](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel))-friendly features with complete data-binding support. This allows you to synchronize a resource’s data from external services and databases into the Scheduler control by using the mapping technique.

You can create a custom resource model with the required field Id, Name, and other optional fields like Background and Foreground. It can be mapped to the equivalent properties in the [ResourceMapping](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_ResourceMapping) API in the **Scheduler** class.

The following code example illustrates the creation of a custom resource.

```csharp
/// <summary>   
/// Represents custom data properties.   
/// </summary> 
public class Employee
{
    public string Name { get; set; }
    public object ID { get; set; }
    public Brush BackgroundBrush { get; set; }
    public Brush ForegroundBrush { get; set; }
}
```

This is how you map a custom resource to the Scheduler control.

```html
<syncfusion:SfScheduler.ResourceMapping>
    <syncfusion:ResourceMapping 
         Id="ID" 
         Name="Name" 
         Background="BackgroundBrush" 
         Foreground="ForegroundBrush"/>
</syncfusion:SfScheduler.ResourceMapping>
```

And this is how you add custom resources to the Scheduler control.

```html
<syncfusion:SfScheduler ViewType="WorkWeek"
                        ResourceGroupType="Resource"
                        ItemsSource="{Binding Tasks}">
    <syncfusion:SfScheduler.ResourceCollection>
      <local:SchedulerResourceCollection>
        <local:Employee Name="Sophia" ID="1" ForegroundBrush="White" BackgroundBrush="#9d65c9" />
        <local:Employee Name="Kinsley Elena" ID="2" ForegroundBrush="White" BackgroundBrush="#f08a5d" />
        <local:Employee Name="Adeline Ruby" ID="3" ForegroundBrush="White" BackgroundBrush="#679b9b" />
      </local:SchedulerResourceCollection>
    </syncfusion:SfScheduler.ResourceCollection>
</syncfusion:SfScheduler>
```

![Creating Custom Resources in Scheduler](https://www.syncfusion.com/blogs/wp-content/uploads/2020/10/Creating-Custom-Resources-in-Scheduler.png)<figcaption>Creating Custom Resources in Scheduler</figcaption>

## Task reassignment

While managing an employee’s workload, sometimes we need to redirect the tasks assigned to that employee to someone else.

In that scenario, you can easily create, edit, or delete the task dynamically using the built-in [editor](https://help.syncfusion.com/wpf/scheduler/appointment-editing) support. You can also easily reassign and reschedule the tasks with [drag-and-drop](https://help.syncfusion.com/wpf/scheduler/appointment-drag-and-drop) support and appointment [resizing](https://help.syncfusion.com/wpf/scheduler/appointment-editing#appointment-resizing) support in the WPF Scheduler control.

![Built-in Editor in WPF Scheduler](https://www.syncfusion.com/blogs/wp-content/uploads/2020/10/Built-in-Editor-in-WPF-Scheduler.png)<figcaption>Built-in Editor in WPF Scheduler</figcaption>

## Resource availability

Resource availability plays a fundamental role in resource management. Knowing the available resources at any given time is an important factor in deciding how to distribute and allocate the right assets for any given project.

You can easily manage and track the absence and unavailability of resources by using the [special time regions](https://help.syncfusion.com/wpf/scheduler/daysview#special-time-regions) support. This feature allows you to maintain the availability of each resource. It is used by adding the resource Id in the [ResourceIdCollection](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SpecialTimeRegion.html#Syncfusion_UI_Xaml_Scheduler_SpecialTimeRegion_ResourceIdCollection) property of the [SpecialTimeRegions](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.TimeSlotViewSettings.html#Syncfusion_UI_Xaml_Scheduler_TimeSlotViewSettings_SpecialTimeRegions) API in [DaysViewSettings](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_DaysViewSettings) for the days view and [TimelineViewSettings](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_TimelineViewSettings) for the timeline view.

Refer to the following code example.

```csharp
SpecialTimeRegion timeRegion = new SpecialTimeRegion();
timeRegion.Text = "Casual leave"
timeRegion.StartTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.AddDays(2).Day, 0, 0, 0);
timeRegion.EndTime = new DateTime(currentDate.Year, currentDate.Month, currentDate.AddDays(3).Day, 0, 0, 0);
timeRegion.Background = new SolidColorBrush(Color.FromRgb(245, 245, 245));
timeRegion.ResourceIdCollection = new ObservableCollection<object>() { "2" };
scheduler.DaysViewSettings.SpecialTimeRegions = new ObservableCollection<SpecialTimeRegion>() { timeRegion };

```

![Scheduler View Showing the Resources’ Appointments](https://www.syncfusion.com/blogs/wp-content/uploads/2020/10/Scheduler-View-Showing-the-Resources%E2%80%99-Appointments.png)<figcaption>Scheduler View Showing the Resources’ Appointments</figcaption>

**GitHub Reference:** This resource view sample can be downloaded from this [GitHub](https://github.com/SyncfusionExamples/ease-resource-allocation-using-the-scheduler-resource-view-in-wpf) location.

## Customization

While managing resources, customizing the view can come in handy when you need to inspect resources that perform different roles within a single team.

The Scheduler resource view allows you to create different colors and even different views based on the employees’ roles in a project by using data templates and data-template selector support. This can be done with the [ResourceHeaderTemplate](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_ResourceHeaderTemplate) and [ResourceHeaderTemplateSelector](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Scheduler.SfScheduler.html#Syncfusion_UI_Xaml_Scheduler_SfScheduler_ResourceHeaderTemplateSelector) APIs in the **Scheduler** class as illustrated in the following code example.

```html
<syncfusion:SfScheduler.ResourceHeaderTemplate>
  <DataTemplate>
    <Grid Background="Transparent">
      <StackPanel VerticalAlignment="Center" Orientation="Vertical">
        <Border CornerRadius="36" Height="72" Width="72" BorderThickness="4" BorderBrush="{Binding BackgroundBrush}">
          <Border CornerRadius="36" Height="64" Width="64" BorderThickness="4" BorderBrush="Transparent">
             <Image HorizontalAlignment="Center" VerticalAlignment="Center"
                    Width="55"
                    Height="55"
                    Source="{Binding ImageSource}" />
           </Border>
       </Border>
       <TextBlock HorizontalAlignment="Center"
           VerticalAlignment="Center"
           FontSize="15"
           Text="{Binding Name}"/>
       <TextBlock HorizontalAlignment="Center"
            VerticalAlignment="Center"
            FontSize="15"
            Text="{Binding Designation}"/>
     </StackPanel>
   </Grid>
  </DataTemplate>
</syncfusion:SfScheduler.ResourceHeaderTemplate>
```

![Resource View Customization](https://www.syncfusion.com/blogs/wp-content/uploads/2020/10/Resource-View-Customization.png)<figcaption>Resource View Customization</figcaption>

**GitHub Reference:** This custom resource view sample can be downloaded from this [GitHub](https://github.com/SyncfusionExamples/ease-resource-allocation-using-the-scheduler-resource-view-in-wpf/tree/main/CustomResourceView) location.

## Conclusion

In this blog post, we had a quick overview of how to easily manage and allocate resources using key features of the [Syncfusion WPF Scheduler control](https://www.syncfusion.com/wpf-ui-controls/scheduler) introduced in the [Essential Studio 2020 Volume 3 release](https://www.syncfusion.com/forums/158306/essential-studio-2020-volume-3-release-v18-3-0-35-is-available-for-download). The features in this control will definitely help manage resources effectively.

Management is a practice where art, science, and craft meet! So, let’s mange our resources wisely with our WPF Scheduler Resource View!

If you are an existing Syncfusion user, please download the latest version from the [License and Downloads](https://www.syncfusion.com/account/downloads) page and try the new features for yourself. Also, our NuGet packages are available on [NuGet.org](https://www.nuget.org/).

If you aren’t a customer yet, you can try our 30-day [free trial](https://www.syncfusion.com/downloads) to check out these features. Also, try our other samples from this [GitHub](https://github.com/SyncfusionExamples) location.

Feel free to share your feedback or questions in the comments section below. You can also contact us through our [support forums](https://www.syncfusion.com/forums), [Direct-Trac](https://www.syncfusion.com/forums), or [feedback portal](https://www.syncfusion.com/feedback/). We are always happy to assist you.