Templating the GroupHeaders
This help article explains in details how to use GroupHeaderContentTemplateSelector in order to set different DataTemplates to the GroupHeaders of RadScheduleView.
The article covers the following topics:
How to generate and use GroupHeaderContentTemplateSelector
Choose one of the following approaches to obtain the source code of GroupHeaderContentTemplateSelector:
Generate GroupHeaderContentTemplateSelector from installation folder - In the UI for WPF installation folder on your computer, go to Themes folder and select the theme that you use in your application. Drill down to find the ScheduleView.xaml file in that directory. From this resource dictionary you can extract the GroupHeaderContentTemplateSelector and any needed resources that it uses.
Generate GroupHeaderContentTemplateSelector from RadScheduleView template - Generate first the RadScheduleView template from Expression Blend ( Edit Template > Edit a Copy). Search for the GroupHeaderContentTemplateSelector and copy the style together with all needed resources that it uses.
The end result should include the following XAML code:
Note the use of the local and telerikPrimitives namespaces from the raw source:
The selector is applied to our instance of RadScheduleView:
How to create a custom GroupHeaderContentTemplateSelector
Let’s, for example, create a custom Resource like this:
And add the EmployeeResource to “Employee” ResourceType. Note that the RadScheduleView is grouped by this resource type.
In order to set different templates to the GroupHeaders , we should create a custom class which inherits ScheduleViewDataTemplateSelector and overrides its SelectTemplate method. Also we need to add the DataTemplates for resource and date GroupHeaders and return the corresponding template:
Add the DataTemplates to the XAML:
Note how the properties of the custom resource are bound using Name property:
Finally, set the GroupHeaderContentTemplateSelector property of the ScheduleView:
Here is the result:
Check out the GroupHeaderTemplate Example at WPF demos to see the GroupHeaderContentTemplateSelector in action.