Back to Devexpress

GanttView.RequestTimescaleRulers Event

wpf-devexpress-dot-xpf-dot-gantt-dot-ganttview-047ee4db.md

latest7.6 KB
Original Source

GanttView.RequestTimescaleRulers Event

Occurs when timescale rulers are visually changed and allows you to edit timescale rulers. This is a routed event.

Namespace : DevExpress.Xpf.Gantt

Assembly : DevExpress.Xpf.Gantt.v25.2.dll

NuGet Package : DevExpress.Wpf.Gantt

Declaration

csharp
public event EventHandler<RequestTimescaleRulersEventArgs> RequestTimescaleRulers
vb
Public Event RequestTimescaleRulers As EventHandler(Of RequestTimescaleRulersEventArgs)

Event Data

The RequestTimescaleRulers event's data class is RequestTimescaleRulersEventArgs. The following properties provide information specific to this event:

PropertyDescription
HandledGets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs.
NonworkingDayVisibilityGets or sets the nonworking day visibility at a current zoom level.
NonworkingTimeVisibilityGets or sets the nonworking time visibility at a current zoom level.
OriginalSourceGets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
SourceGets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.
TimescaleRulersGet or sets a collection of timescale rulers displayed at the current zoom level.
ZoomGets the current zoom.

The event data class exposes the following methods:

MethodDescription
InvokeEventHandler(Delegate, Object)When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs.
OnSetSource(Object)When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs.

Remarks

The RequestTimescaleRulers event occurs on init, when the Gantt area is zoomed and when the TimescaleRulerCount property value is changed.

Handle the RequestTimescaleRulers event to dynamically change the following:

csharp
private void view_RequestTimescaleRulers(object sender, DevExpress.Xpf.Gantt.RequestTimescaleRulersEventArgs e) {
    // Remove a ruler from timescale
    e.TimescaleRulers.RemoveAt(1);
    // Add a ruler that indicates hours
    e.TimescaleRulers.Add(new DevExpress.Xpf.Gantt.TimescaleRuler(DevExpress.Xpf.Gantt.TimescaleUnit.Hour));
    // Add a ruler that indicates 30 minute ranges
    e.TimescaleRulers.Add(new DevExpress.Xpf.Gantt.TimescaleRuler(DevExpress.Xpf.Gantt.TimescaleUnit.Minute, 30));

    // Nonworking dates and nonworking time are not indicated with a specific background
    e.NonworkingDayVisibility = Visibility.Hidden;
    e.NonworkingTimeVisibility = Visibility.Hidden;
}
vb
Private Sub view_RequestTimescaleRulers(ByVal sender As Object, ByVal e As DevExpress.Xpf.Gantt.RequestTimescaleRulersEventArgs)
    ' Remove a ruler from timescale
    e.TimescaleRulers.RemoveAt(1)
    ' Add a ruler that indicates hours
    e.TimescaleRulers.Add(New DevExpress.Xpf.Gantt.TimescaleRuler(DevExpress.Xpf.Gantt.TimescaleUnit.Hour))
    ' Add a ruler that indicates 30 minute ranges
    e.TimescaleRulers.Add(New DevExpress.Xpf.Gantt.TimescaleRuler(DevExpress.Xpf.Gantt.TimescaleUnit.Minute, 30))

    ' Nonworking dates and nonworking time are not indicated with a specific background
    e.NonworkingDayVisibility = Visibility.Hidden
    e.NonworkingTimeVisibility = Visibility.Hidden
End Sub

The RequestTimescaleRulers event allows you to add timescale rulers with custom formats:

  1. Create a class that implements IFormatProvider and ICustomFormatter interfaces.

  2. In this class, specify the ruler’s text and format. The following code sample displays months or two-month ranges based on the zoom level:

  3. Add a new timescale ruler and pass your custom format to its FormatProvider property:

See Also

GanttView Class

GanttView Members

DevExpress.Xpf.Gantt Namespace