Class
DateTimePicker

This class represents a control that provides functionality for choosing dates or times. It supports value ranges and value formats.

Definition

Namespace:Telerik.UI.Xaml.Controls.Input

Assembly:Telerik.WinUI.Controls.dll

Syntax:

cs-api-definition
public abstract class DateTimePicker : RadHeaderedControl

Inheritance: objectRadControlRadHeaderedControlDateTimePicker

Derived Classes: RadDateTimePicker

Inherited Members RadHeaderedControl.HeaderPropertyRadHeaderedControl.HeaderTemplatePropertyRadHeaderedControl.HeaderStylePropertyRadHeaderedControl.HeaderRadHeaderedControl.HeaderTemplateRadHeaderedControl.HeaderStyleRadControl.EndVisualStateUpdate(bool, bool)RadControl.UpdateVisualState(bool)RadControl.BeginVisualStateUpdate()RadControl.SetVisualState(string, bool)RadControl.CanUpdateVisualState()RadControl.ComposeVisualStateName()RadControl.ArrangeOverride(Size)RadControl.OnApplyTemplate()RadControl.OnIsEnabledChanged(bool, bool)RadControl.LoadCore()RadControl.OnLoaded()RadControl.CurrentVisualStateRadControl.IsLoadedRadControl.IsLoadingRadControl.IsUnloadedRadControl.WasUnloadedRadControl.IsTemplateApplied

Constructors

DateTimePicker()

Initializes a new instance of the DateTimePicker class.

Declaration

cs-api-definition
protected DateTimePicker()

Fields

AutoSizeWidthProperty

Identifies the AutoSizeWidth dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty AutoSizeWidthProperty

Field Value

DependencyProperty

CalendarIdentifierProperty

Identifies the CalendarIdentifier dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty CalendarIdentifierProperty

Field Value

DependencyProperty

CalendarLanguageProperty

Identifies the CalendarLanguage dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty CalendarLanguageProperty

Field Value

DependencyProperty

CalendarNumeralSystemProperty

Identifies the CalendarNumeralSystem dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty CalendarNumeralSystemProperty

Field Value

DependencyProperty

DateSelectorOrderProperty

Identifies the DateSelectorOrder dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty DateSelectorOrderProperty

Field Value

DependencyProperty

DisplayModeProperty

Identifies the DisplayMode dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty DisplayModeProperty

Field Value

DependencyProperty

DisplayValueFormatProperty

Identifies the DisplayValueFormat dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty DisplayValueFormatProperty

Field Value

DependencyProperty

EmptyContentProperty

Identifies the EmptyContent dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty EmptyContentProperty

Field Value

DependencyProperty

EmptyContentTemplateProperty

Declaration

cs-api-definition
public static readonly DependencyProperty EmptyContentTemplateProperty

Field Value

DependencyProperty

IsOpenProperty

Identifies the IsOpen dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty IsOpenProperty

Field Value

DependencyProperty

IsReadOnlyProperty

Identifies the IsReadOnly dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty IsReadOnlyProperty

Field Value

DependencyProperty

ItemCountProperty

Identifies the ItemCount property.

Declaration

cs-api-definition
public static readonly DependencyProperty ItemCountProperty

Field Value

DependencyProperty

ItemHeightProperty

Identifies the ItemHeight property.

Declaration

cs-api-definition
public static readonly DependencyProperty ItemHeightProperty

Field Value

DependencyProperty

ItemSpacingProperty

Identifies the ItemSpacing property.

Declaration

cs-api-definition
public static readonly DependencyProperty ItemSpacingProperty

Field Value

DependencyProperty

ItemWidthProperty

Identifies the ItemWidth property.

Declaration

cs-api-definition
public static readonly DependencyProperty ItemWidthProperty

Field Value

DependencyProperty

MaxValueProperty

Identifies the MaxValue dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty MaxValueProperty

Field Value

DependencyProperty

MinValueProperty

Identifies the MinValue dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty MinValueProperty

Field Value

DependencyProperty

SelectorBackgroundStyleProperty

Identifies the SelectorBackgroundStyle dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty SelectorBackgroundStyleProperty

Field Value

DependencyProperty

SelectorDefaultValueProperty

Identifies the SelectorDefaultValue dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty SelectorDefaultValueProperty

Field Value

DependencyProperty

SelectorHeaderProperty

Identifies the SelectorHeader dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty SelectorHeaderProperty

Field Value

DependencyProperty

SelectorHeaderTemplateProperty

Identifies the SelectorHeaderTemplate dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty SelectorHeaderTemplateProperty

Field Value

DependencyProperty

StepProperty

Identifies the Step dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty StepProperty

Field Value

DependencyProperty

TimeSelectorOrderProperty

Identifies the TimeSelectorOrder dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty TimeSelectorOrderProperty

Field Value

DependencyProperty

ValueProperty

Identifies the Value dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty ValueProperty

Field Value

DependencyProperty

ValueStringProperty

Identifies the ValueString dependency property.

Declaration

cs-api-definition
public static readonly DependencyProperty ValueStringProperty

Field Value

DependencyProperty

selectorUtcValue

Declaration

cs-api-definition
protected DateTime selectorUtcValue

Field Value

DateTime

Properties

AutoSizeWidth

Gets or sets a value indicating whether the control will automatically calculate its width so that it equals the width of the Selector part. The default value is true.

Declaration

cs-api-definition
public bool AutoSizeWidth { get; set; }

Property Value

bool

Default value: true

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" AutoSizeWidth="False"/>
c
datePicker.AutoSizeWidth = false;

CalendarIdentifier

Gets or sets the calendar identifier. The default value is .

Declaration

cs-api-definition
public string CalendarIdentifier { get; set; }

Property Value

string

CalendarLanguage

Gets or sets the calendar language. The default value is .

Declaration

cs-api-definition
public string CalendarLanguage { get; set; }

Property Value

string

CalendarNumeralSystem

Gets or sets the calendar numeral system. The default value is .

Declaration

cs-api-definition
public string CalendarNumeralSystem { get; set; }

Property Value

string

DateSelectorOrder

Gets or sets the date selector format. This value defines which DateTimeItem parts of the selector will be visible and how they will be ordered. For example setting "ym" will display the Year and Month items in a RadDatePicker instance.

Declaration

cs-api-definition
public string DateSelectorOrder { get; set; }

Property Value

string

Options available for RadDatePicker: "y" (year), "m" (month), "d" (day)

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" DateSelectorOrder="ym"/>
C
datePicker.SelectorOrder = "ym";

DisplayMode

Gets or sets the mode that defines how the component is displayed within the visual tree. The default value is Standard.

Declaration

cs-api-definition
public DateTimePickerDisplayMode DisplayMode { get; set; }

Property Value

DateTimePickerDisplayMode

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" DisplayMode="Standard"/>
c
datePicker.DisplayMode = DateTimePickerDisplayMode.Standard;

DisplayValueFormat

Gets or sets the format for the string being displayed The default value is Empty.

Declaration

cs-api-definition
public string DisplayValueFormat { get; set; }

Property Value

string

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" DisplayValueFormat="dd-MM-yyyy"/>
c
datePicker.DisplayValueFormat = "dd-MM-yyyy";

EmptyContent

Gets or sets the null text of the control. The null text is displayed when there is no value defined.

Declaration

cs-api-definition
public object EmptyContent { get; set; }

Property Value

object

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" EmptyContent="No date is selected."/>
c
datePicker.EmptyContent = "No date is selected.";

EmptyContentTemplate

Gets or sets the DataTemplate defining the visual appearance of the empty content of the control.

Declaration

cs-api-definition
public DataTemplate EmptyContentTemplate { get; set; }

Property Value

DataTemplate

The empty content DataTemplate.

Example

xaml
<telerikInput:RadDatePicker>
    <telerikInput:RadDatePicker.EmptyContentTemplate>
        <DataTemplate>
            <TextBlock Text="No content" Foreground="Red" FontWeight="Bold"/>
        </DataTemplate>
    </telerikInput:RadDatePicker.EmptyContentTemplate>
</telerikInput:RadDatePicker>

IsOpen

Gets or sets a value indicating whether the selector part of the control is opened.

Declaration

cs-api-definition
public bool IsOpen { get; set; }

Property Value

bool

Default value: false.

Remarks

If the DisplayMode property is set to Inline, the selector part is always visible.

IsReadOnly

Gets or sets a value indicating whether the control is in read only mode. If set to true, the control does not allow the user to modify its value.

Declaration

cs-api-definition
public bool IsReadOnly { get; set; }

Property Value

bool

Default value: false.

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" IsReadOnly="True"/>
c
datePicker.IsReadOnly = true;

ItemCount

Gets or sets the number of items visible within the selector part of the picker. This property is used to determine the height of the selector part when opened.

Declaration

cs-api-definition
public int ItemCount { get; set; }

Property Value

int

Default value: 7

When the value is set to negative number, the selector part maximizes its height to fit the height of the current root visual.

Remarks

The calculated height will not exceed the height of the current top-level Window.

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" ItemCount="8"/>
c
datePicker.ItemCount = 8;

ItemHeight

Gets or sets the height of the DateTimeItem that appear in the selector part of the picker.

Declaration

cs-api-definition
public double ItemHeight { get; set; }

Property Value

double

Example

xaml
<telerikInput:RadDateTimePicker x:Name="dateTimePicker" ItemHeight="50"/>
c
dateTimePicker.ItemHeight = 50;

ItemSpacing

Gets or sets the margin of the DateTimeItem that appear in the selector part of the DateTimePicker.

Declaration

cs-api-definition
public double ItemSpacing { get; set; }

Property Value

double

Default value: 5.

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" ItemSpacing="15"/>
c
datePicker.ItemSpacing = 15;

ItemWidth

Gets or sets the width of the DateTimeItem that appear in the selector part of the picker.

Declaration

cs-api-definition
public double ItemWidth { get; set; }

Property Value

double

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" ItemWidth="100"/>
c
datePicker.ItemWidth = 100;

MaxValue

Gets or sets the maximum value of the Value property range for the control.

Declaration

cs-api-definition
public DateTime MaxValue { get; set; }

Property Value

DateTime

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker"/>
c
datePicker.MaxValue = new DateTime(2014, 1, 1);

MinValue

Gets or sets the minimum value of the Value property range for the control.

Declaration

cs-api-definition
public DateTime MinValue { get; set; }

Property Value

DateTime

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker"/>
c
datePicker.MaxValue = new DateTime(2012, 1, 1);

SelectorBackgroundStyle

Gets or sets the Style instance that defines the fill and border of the Selector part of the control. The Style should target the Border type.

Declaration

cs-api-definition
public Style SelectorBackgroundStyle { get; set; }

Property Value

Style

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker">
    <telerikInput:RadDatePicker.SelectorBackgroundStyle>
        <Style TargetType="Border">
            <Setter Property="Background" Value="Bisque"/>
            <Setter Property="BorderBrush" Value="RoyalBlue"/>
            <Setter Property="BorderThickness" Value="5"/>
        </Style>
    </telerikInput:RadDatePicker.SelectorBackgroundStyle>
</telerikInput:RadDatePicker>

SelectorDefaultValue

Gets or sets an instance of the DateTime struct that represents the default value displayed in the selector part when opened. The default value is shown when the Value property is set to null.

Declaration

cs-api-definition
public DateTime? SelectorDefaultValue { get; set; }

Property Value

DateTime?

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" />
c
datePicker.SelectorDefaultValue = new DateTime(2021, 10, 11);

SelectorHeader

Gets or sets the header displayed in the selector part of the DateTimePicker instance.

Declaration

cs-api-definition
public object SelectorHeader { get; set; }

Property Value

object

Default value: null

Remarks

If the value is null, the default displayed text is "Select Date"/"Select Time" for RadDatePicker/RadTimePicker.

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker" SelectorHeader="Enter your birthday"/>
c
datePicker.SelectorHeader = "Enter your birthday:";

SelectorHeaderTemplate

Gets or sets an instance of the DataTemplate class that represents the template used to visualize the content defined by the SelectorHeader property.

Declaration

cs-api-definition
public DataTemplate SelectorHeaderTemplate { get; set; }

Property Value

DataTemplate

Example

xaml
<telerikInput:RadDatePicker>
    <telerikInput:RadDatePicker.SelectorHeaderTemplate>
        <DataTemplate>
            <TextBlock Text="Enter your birthday" Foreground="Orange"
                       FontSize="20" FontWeight="Bold" Margin="10,10,10,10"/>
        </DataTemplate>
    </telerikInput:RadDatePicker.SelectorHeaderTemplate>
</telerikInput:RadDatePicker>

Step

Gets or sets an instance of the DateTimePickerStep struct that represents the date or time amount used as an interval to create the selectable options in the date/time component selectors.

Declaration

cs-api-definition
public DateTimePickerStep Step { get; set; }

Property Value

DateTimePickerStep

TimeSelectorOrder

Declaration

cs-api-definition
public string TimeSelectorOrder { get; set; }

Property Value

string

Value

Gets or sets the date value.

Declaration

cs-api-definition
public DateTime? Value { get; set; }

Property Value

DateTime?

The default value is null or defined by the EmptyContent or EmptyContentTemplate properties.

Remarks

The range of the value is defined by the MinValue and MaxValue properties.

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker"/>
c
datePicker.Value = new DateTime(2022, 1, 1);

ValueString

Gets the string representation of the current value. The string representation is the current value formatted according to the settings of the device and the control.

Declaration

cs-api-definition
public string ValueString { get; }

Property Value

string

Default value: null

When no date is selected, the text displayed in the button part is defined by the EmptyContent or the EmptyContentTemplate properties.

Example

xaml
<telerikInput:RadDatePicker x:Name="datePicker"/>
c
datePicker.Value = new DateTime(2022,1,1);
string date = datePicker.ValueString;// "1/1/2022"

Methods

ApplyTemplateCore()

Resolves the control's template parts.

Declaration

cs-api-definition
protected override bool ApplyTemplateCore()

Returns

bool

Overrides RadControl.ApplyTemplateCore()

GetValueStringFromCalendar(Calendar)

Gets the string that represents the Value according to the calendar. Override this method to change the default ValueString.

Declaration

cs-api-definition
protected virtual string GetValueStringFromCalendar(Calendar calendar)

Parameters

calendar

Calendar

Returns

string

MeasureOverride(Size)

Provides the behavior for the Measure pass of the layout cycle.

Declaration

cs-api-definition
protected override Size MeasureOverride(Size availableSize)

Parameters

availableSize

Size

Returns

Size

Overrides RadControl.MeasureOverride(Size)

OnCreateAutomationPeer()

Declaration

cs-api-definition
protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer

Overrides RadHeaderedControl.OnCreateAutomationPeer()

OnKeyDown(KeyRoutedEventArgs)

Called before the KeyDown event occurs.

Declaration

cs-api-definition
protected override void OnKeyDown(KeyRoutedEventArgs e)

Parameters

e

KeyRoutedEventArgs

The data for the event.

OnTemplateApplied()

Occurs when the method has been called and the template is already successfully applied.

Declaration

cs-api-definition
protected override void OnTemplateApplied()

Overrides RadControl.OnTemplateApplied()

UnapplyTemplateCore()

Removes the current control template. Occurs when a template has already been applied and a new one is applied.

Declaration

cs-api-definition
protected override void UnapplyTemplateCore()

Overrides RadControl.UnapplyTemplateCore()

UnloadCore()

Called within the handler of the event. Allows inheritors to provide their specific logic.

Declaration

cs-api-definition
protected override void UnloadCore()

Overrides RadControl.UnloadCore()

Events

Closed

This event is raised when the selector part of the DateTimePicker control has been closed.

Declaration

cs-api-definition
public event EventHandler Closed

Event Value

EventHandler

Opened

This event is raised when the selector part of the DateTimePicker control has been opened.

Declaration

cs-api-definition
public event EventHandler Opened

Event Value

EventHandler

ValueChanged

This event is raised when the Value property has changed.

Declaration

cs-api-definition
public event EventHandler ValueChanged

Event Value

EventHandler