All docs
V21.2
21.2
21.1
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

SchedulerViewBase.TimeRegionContentTemplateSelector Property

Specifies the object that chooses a time region template based on custom logic. This is a dependency property.

Namespace: DevExpress.Xpf.Scheduling

Assembly: DevExpress.Xpf.Scheduling.v21.2.dll

Declaration

public DataTemplateSelector TimeRegionContentTemplateSelector { get; set; }

Property Value

Type Description
DataTemplateSelector

A System.Windows.Controls.DataTemplateSelector descendant that chooses a template based on custom logic.

Remarks

A template that defines the presentation of time regions is specified by the TimeRegionContentTemplate property.

The example below illustrates how to apply different templates based on the time region’s Start property value:

     <dx:ThemedWindow.Resources>
        <DataTemplate  x:Key="timeRegionTextContentTemplate">
            <TextBlock Text="Break" VerticalAlignment="Center" HorizontalAlignment="Center"/>
        </DataTemplate>
        <DataTemplate  x:Key="timeRegionImageContentTemplate">
            <Image MaxHeight="28"
            Source="{dx:SvgImageSource Uri='pack://application:,,,/DevExpress.Images.v21.2;component/SvgImages/Icon Builder/Travel_Restaurant.svg'}" />
        </DataTemplate>
        <local:TimeRegionTemplateSelector x:Key="timeRegionTemplateSelector"
                                          TimeRegionTextContentTemplate="{StaticResource timeRegionTextContentTemplate}"
                                          TimeRegionImageContentTemplate="{StaticResource timeRegionImageContentTemplate}"/>
    </dx:ThemedWindow.Resources>
    ...
    <dxsch:SchedulerControl>
        <dxsch:SchedulerControl.TimeRegionItems>
            <dxsch:TimeRegionItem Start="{x:Static sys:DateTime.Today}" End="{x:Static sys:DateTime.Now}"
                                  BrushName="{x:Static dxsch:DefaultBrushNames.TimeRegion1Hatch}"
                                  />
        </dxsch:SchedulerControl.TimeRegionItems>
        <dxsch:DayView TimeRegionContentTemplateSelector="{StaticResource timeRegionTemplateSelector}" />
    </dxsch:SchedulerControl>
public class TimeRegionTemplateSelector : DataTemplateSelector {
    public DataTemplate TimeRegionTextContentTemplate { get; set; }
    public DataTemplate TimeRegionImageContentTemplate { get; set; }

    public override DataTemplate SelectTemplate(object item, DependencyObject container) {
        TimeRegionViewModel timeRegion = item as TimeRegionViewModel;
        if (timeRegion != null)
            return (timeRegion.TimeRegion.Start.Hour > 18) ? TimeRegionImageContentTemplate : TimeRegionTextContentTemplate;
        return base.SelectTemplate(item, container);
    }
}
See Also