Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (143).NET Core  (23)Angular  (39)ASP.NET  (47)ASP.NET Core  (53)ASP.NET MVC  (83)Azure  (26)Blazor  (47)DocIO  (18)Essential JS 2  (64)Essential Studio  (159)Flutter  (52)JavaScript  (134)Microsoft  (96)PDF  (48)React  (29)Succinctly series  (118)Syncfusion  (399)TypeScript  (30)Uno Platform  (2)UWP  (4)Vue  (25)Webinar  (14)Windows Forms  (52)WPF  (92)Xamarin  (105)XlsIO  (20)Other CategoriesBarcode  (4)BI  (29)Bold BI  (3)Build conference  (6)Business intelligence  (53)Button  (4)C#  (99)Chart  (40)Cloud  (8)Company  (445)Dashboard  (4)Data Science  (3)Data Validation  (2)DataGrid  (31)Development  (233)Doc  (7)eBook  (89)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (13)Extensions  (7)File Manager  (3)Gantt  (6)Gauge  (4)Git  (3)Grid  (24)HTML  (8)Installer  (1)Knockout  (2)LINQPad  (1)Linux  (1)M-Commerce  (1)Metro Studio  (11)Mobile  (139)Mobile MVC  (9)OLAP server  (1)Orubase  (12)Partners  (20)PDF viewer  (15)Performance  (2)PHP  (1)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (5)Road Map  (9)Scheduler  (15)SfDataGrid  (7)Silverlight  (21)Sneak Peek  (12)Solution Services  (2)Spreadsheet  (2)SQL  (4)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (9)Tips and Tricks  (15)UI  (62)Uncategorized  (68)Unix  (2)User interface  (48)Visual State Manager  (1)Visual Studio  (12)Visual Studio Code  (7)Web  (96)What's new  (61)Windows 8  (19)Windows App  (1)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Share on twitter
Share on facebook
Share on linkedin
Easily Allocate Resources with the Resource View in WPF Scheduler

Easily Allocate Resources with the Resource View in WPF Scheduler

“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. If you are new to our Scheduler control, please read the getting started article in the Scheduler documentation 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 API in the Scheduler class with the required fields like Id and Name, and optional fields like Background and Foreground and so on.
Refer to the following code example.

<syncfusion:SfScheduler ViewType="WorkWeek">
  <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 API of the ScheduleAppointment class like in the following code example.

// 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
Associating Resources with Appointments

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 API in the Scheduler 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.

// Sets resource group type as Resource.
<syncfusion:SfScheduler ViewType="WorkWeek" ResourceGroupType="Resource" >
</syncfusion:SfScheduler>
Group by Resource
Group by Resource
Group by Date
Group by Date

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
Resource Sharing

Data binding

The resource view provides MVVM (model- view-viewmodel)-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 API in the Scheduler class.

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

/// <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.

<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.

<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
Creating Custom Resources in Scheduler

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 support. You can also easily reassign and reschedule the tasks with drag-and-drop support and appointment resizing support in the WPF Scheduler control.

Built-in Editor in WPF Scheduler
Built-in Editor in WPF Scheduler

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 support. This feature allows you to maintain the availability of each resource. It is used by adding the resource Id in the ResourceIdCollection property of the SpecialTimeRegions API in DaysViewSettings for the days view and TimelineViewSettings for the timeline view.

Refer to the following code example.

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
Scheduler View Showing the Resources’ Appointments

GitHub Reference: This resource view sample can be downloaded from this GitHub 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 and ResourceHeaderTemplateSelector APIs in the Scheduler class as illustrated in the following code example.

<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
Resource View Customization

GitHub Reference: This custom resource view sample can be downloaded from this GitHub 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 introduced in the Essential Studio 2020 Volume 3 release. 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 page and try the new features for yourself. Also, our NuGet packages are available on NuGet.org.

If you aren’t a customer yet, you can try our 30-day free trial to check out these features. Also, try our other samples from this GitHub location.

Feel free to share your feedback or questions in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you.

Tags:

Share this post:

Share on twitter
Share on facebook
Share on linkedin

Leave a comment

Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top