Custom Interval Types
RadTimeline provides built-in support for a couple of predefined interval types ranging from milliseconds to centuries. For a full list of the predefined intervals, please refer to the Interval Formatters article. For all custom scenarios that the predefined intervals do not cover, the control supports custom interval type implementations.
Using Custom interval types
The Intervals collection contains items of type IntervalBase. That is why, in order to configure a RadTimeline control to use a custom interval type, simply add an instance of that custom interval to the Intervals collection of the control.
The example below shows how you can add a custom interval type to the Intervals collection of a RadTimeline control:
The IntervalBase class
A custom interval is a class that inherits the IntervalBase class and implements its abstract properties and methods:
- Formatters – Gets a collection of formatter that the interval can use to convert DateTime objects to strings.
- MinimumPeriodLength - Gets the smallest interval period.
- ExtractIntervalStart – Given a DateTime object, this method returns the start of the interval that contains the given DateTime object.
- IncrementByInterval – Given a DateTime object and span, this method increments the specified DateTime object by the specified number of MinimumPeriodLengths
Below you can find a sample custom interval implementation:
Find a runnable project of the previous example in the WPF Samples GitHub repository.
Using the sample custom interval above, you will get the following result: