- Date interval
- Auto interval
Contact Support
Interval in .NET MAUI DateTime Slider (SfDateTimeSlider)
This section explains how to add the interval for DateTime Slider.
Date interval
Slider elements like labels, ticks, and dividers are rendered based on the Interval
, Minimum
, and Maximum
properties. The default value is 0
.
Change the interval type using the IntervalType
property. Format or change the label text using the DateFormat
property.
For example, if the Minimum
is DateTime(2000, 01, 01)
, the Maximum
is DateTime(2005, 01, 01)
, and Interval
is 1
, IntervalType
is SliderDateIntervalType.Years
, DateFormat
is yyyy
then the Slider will render the labels, major ticks, and dividers at 2000, 2001, 2002, and so on.
<sliders:SfDateTimeSlider Minimum="2000-01-01"
Maximum="2004-01-01"
Value="2002-01-01"
Interval="1"
DateFormat="yyyy"
IntervalType="Years"
ShowLabels="True"
ShowTicks="True"
ShowDividers="True" />
SfDateTimeSlider slider = new SfDateTimeSlider()
{
Minimum = new DateTime(2010, 01, 01),
Maximum = new DateTime(2004, 01, 01),
Value = new DateTime(2002, 01, 01),
Interval = 1,
IntervalType = SliderDateIntervalType.Years,
DateFormat = "yyyy",
ShowLabels = true,
ShowTicks = true,
ShowDividers = true,
};
Auto interval
If the ShowTicks
or ShowLabels
, or ShowDividers
properties are True
, but the Interval
is 0
, the Interval
will be calculated from the available size. If the IntervalType
or DateFormat
properties are not set, their values too will be calculated.
For example, if the Minimum
is DateTime(2000, 01, 01)
, the Maximum
is DateTime(2001, 01, 01)
, Interval
is 0
, and consider the available size as 350, then the Slider will render the labels, major ticks, and dividers at Jan 01, 2000
, Jul 01, 2000
, and Nov 01, 2000
respectively.
<sliders:SfDateTimeSlider Minimum="2000-01-01"
Maximum="2004-01-01"
Value="2002-01-01"
ShowLabels="True"
ShowTicks="True"
ShowDividers="True" />
SfDateTimeSlider slider = new SfDateTimeSlider()
{
Minimum = new DateTime(2010, 01, 01),
Maximum = new DateTime(2004, 01, 01),
Value = new DateTime(2002, 01, 01),
ShowLabels = true,
ShowTicks = true,
ShowDividers = true,
};