Skip to main content

How to: Customize Visible Resource Coloring (legacy)

  • 3 minutes to read


You are viewing documentation for the legacy WPF Scheduler control. If you’re starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.

This example demonstrates how to use the SchedulerControl.QueryResourceColorSchema event and SchedulerControl.GetResourceColorSchemasCopy method to link a specific color schema to each visible resource and specify a custom color schema for the selected resource, if more than one resource is displayed in the scheduler view.


A complete sample project is available in the DevExpress Code Examples database at

using System;
using System.Data;
using System.Windows;
using DevExpress.XtraScheduler;
using System.Collections.Generic;
// ...

namespace WpfApplication1 {
    public partial class MainWindow : Window {

        Dictionary<object, SchedulerColorSchema> resourceColorSchemas = 
            new Dictionary<object, SchedulerColorSchema>();

        public MainWindow() {

            // ...

            // Get copies of color schemas that are currently used to paint resources.

        // ...

        private void PrepareResourceColorSchemas() {
            int count = schedulerControl1.Storage.ResourceStorage.Count;
            SchedulerColorSchemaCollection currentColorchemas = 
            int schemaCount = currentColorchemas.Count;
            for (int i = 0; i < count; i++) {
                Resource resource = schedulerControl1.Storage.ResourceStorage[i];
                resourceColorSchemas.Add(resource.Id, currentColorchemas[i % schemaCount]);

        private void schedulerControl1_QueryResourceColorSchema(object sender, 
                                                                QueryResourceColorSchemaEventArgs e) {
            object key = e.Resource.Id;
            if (this.resourceColorSchemas.ContainsKey(key))
                e.ResourceColorSchema = this.resourceColorSchemas[key];

            // Specify the custom color schema for the selected resource 
            // if there are more than one visible resources.
            if ShouldHighlightResource(e.Resource)) {
                e.ResourceColorSchema = new SchedulerColorSchema(Color.LightCyan);

        protected bool ShouldHighlightResource(Resource resource) { 
            if (schedulerControl1.ActiveView.GetResources().Count <= 1)
                return false;

            return schedulerControl1.SelectedResource.Equals(resource);

        Resource selectedResource = Resource.Empty;
        private void schedulerControl1_SelectionChanged(object sender, EventArgs e) {
            if (!selectedResource.Equals(schedulerControl1.SelectedResource)) {
                selectedResource = schedulerControl1.SelectedResource;