A newer version of this page is available. Switch to the current version.

TimeRuler Class

A time ruler for the SchedulerControl.

Namespace: DevExpress.Xpf.Scheduling

Assembly: DevExpress.Xpf.Scheduling.v19.1.dll

Declaration

public class TimeRuler :
    SchedulerFrameworkComponent
Public Class TimeRuler
    Inherits SchedulerFrameworkComponent

Related API Members

The following members accept/return TimeRuler objects:

Remarks

Time rulers can be shown in the Day View, WorkWeek View and Week View Scheduler views.

Time rulers display the time of the view's visible interval, specified by the DayViewBase.VisibleTime property. A view may have several rulers, contained in the DayViewBase.TimeRulers collection.

WPFScheduler_TimeRuler

The time ruler's TimeRuler.Caption property specifies the ruler's caption - a text shown in the header. Commonly, captions are used to indicate a time zone or geographical region whose standard time a ruler displays. A time zone whose time a time ruler displays is specified by the TimeRuler.TimeZone property.

The TimeRuler.ShowMinutes property allows you to specify whether minutes are displayed.

The DayViewBase.TimeMarkerVisibility property allows you to show or hide the time marker - a visual element indicating the current time.

The following code defines a Day View with two time rulers. The time ruler's time indicator is visible only when the view contains the current date. The time rulers display different time zones - one ruler is set for LA, the other for NYC.

<dxsch:DayView TimeMarkerVisibility="TodayView">
    <dxsch:DayView.TimeRulers>
        <dxsch:TimeRulerCollection>
            <dxsch:TimeRuler ShowMinutes="False"
                             TimeZone="Pacific Standard Time"
                             Caption="LA"/>
            <dxsch:TimeRuler ShowMinutes="True"
                             TimeZone="Eastern Standard Time"
                             Caption="NYC"/>
        </dxsch:TimeRulerCollection>
    </dxsch:DayView.TimeRulers>
</dxsch:DayView>

Examples

The following example demonstrates how to add multiple time rulers to the scheduler's Day View using the MVVM architectural pattern.

Use the DayViewBase.TimeRulersSource property to bind the view to a collection of objects containing time ruler settings described in the ViewModel. The DayViewBase.TimeRulerTemplate property specifies a data template based on which time rulers are generated.

Create a custom style for the TimeRulerCellControl to specify format strings for displaying time in the time rulers' time scale.

<dx:ThemedWindow x:Class="WpfSchedulerTimeRulers.MainWindow" mc:Ignorable="d" Title="Time Rulers" Height="500" Width="800" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:local="clr-namespace:WpfSchedulerTimeRulers"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/scheduling"
    xmlns:dxschv="http://schemas.devexpress.com/winfx/2008/xaml/scheduling/visual"
    DataContext="{dxmvvm:ViewModelSource local:MainViewModel}">

    <dx:ThemedWindow.Resources>
        <DataTemplate x:Key="TimeRulerGeneratorTemplate">
            <ContentControl>
                <dxsch:TimeRuler Caption="{Binding Caption}" ShowMinutes="{Binding ShowMinutes}" TimeZone="{Binding TimeZone}" AlwaysShowTimeDesignator="{Binding AlwaysShowTimeDesignator}"/>
            </ContentControl>
        </DataTemplate>

        <Style TargetType="{x:Type dxschv:TimeRulerCellControl}">
            <Setter Property="HourStringFormat" Value="{}{0:HH}"/>
            <Setter Property="MinuteStringFormat" Value="{}{0:mm}"/>
        </Style>
    </dx:ThemedWindow.Resources>

    <Grid>
        <dxsch:SchedulerControl x:Name="scheduler">
            <dxsch:DayView x:Name="dayView" ShowWorkTimeOnly="True" TimeScale="00:30:00" TimeRulersSource="{Binding TimeRulers}" TimeRulerTemplate="{StaticResource TimeRulerGeneratorTemplate}"/>
        </dxsch:SchedulerControl>
    </Grid>
</dx:ThemedWindow>

Inheritance

Object
DispatcherObject
DependencyObject
ContentElement
FrameworkContentElement
DXFrameworkContentElement
DevExpress.Xpf.Scheduling.Internal.SchedulerFrameworkComponent
TimeRuler
See Also