In my previous blog post I discussed appointment data binding for ComponentOne Scheduler for WinRT XAML. With C1Scheduler, there are several data storage collections that you can customize such as labels and availability statuses. The data binding techniques used for appointments can also be used for other collections. In this post I will show how you can customize the appointment labels by binding to a custom collection. Scheduler_Labels_small You’ll notice under the DataStorage property there’s more than just Appointment storage. You can also bind labels and availability statuses to your own custom collections. For example, let’s quickly create a custom collection of labels. Consider the following Label class implementation:

public class Label  
    public int Index { get; set; }  
    public string Text { get; set; }  
    public string Color { get; set; }  

Expose a collection of the Label class in your View Model, and instantiate the colors as strings like below.

public List<Label> Labels { get; private set; }  

private void CreateLabels()  
    this.Labels = new List<Label>();  
    this.Labels.Add(new Label { Text = "Lime", Color = "255,164,196,0", Index = 1 });  

The colors are represented as A,R,G,B strings so that they are easy to serialize without restriction. Then add several NestedPropertySetters to bind and map the Labels collection to the C1Scheduler control.

<c1sched:C1Scheduler x:Name="scheduler">  
    Value="{Binding Path = Labels, Source={StaticResource mainViewModel}}" />  

If you’re creating custom labels and statuses, it’s important to include an Index or Id field so the scheduler can store this information along with the Appointment Properties. The Appointment Properties field is an XML formatted string that includes all of the extra data associated with an appointment such as Private, reminder settings, and label information. If you're working in code and not using MVVM, you can simply set the nested properties directly.


This post is just a quick guide to creating a custom label collection and binding it to C1Scheduler. For a more complete sample that includes the complete View Model, see my previous blog post.