ClassDateTimePicker
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:
public abstract class DateTimePicker : RadHeaderedControl
Inheritance: objectRadControlRadHeaderedControlDateTimePicker
Derived Classes:
Inherited Members
Constructors
DateTimePicker()
Initializes a new instance of the DateTimePicker class.
Declaration
protected DateTimePicker()
Fields
AutoSizeWidthProperty
Identifies the AutoSizeWidth dependency property.
Declaration
public static readonly DependencyProperty AutoSizeWidthProperty
Field Value
DependencyProperty
CalendarIdentifierProperty
Identifies the CalendarIdentifier dependency property.
Declaration
public static readonly DependencyProperty CalendarIdentifierProperty
Field Value
DependencyProperty
CalendarLanguageProperty
Identifies the CalendarLanguage dependency property.
Declaration
public static readonly DependencyProperty CalendarLanguageProperty
Field Value
DependencyProperty
CalendarNumeralSystemProperty
Identifies the CalendarNumeralSystem dependency property.
Declaration
public static readonly DependencyProperty CalendarNumeralSystemProperty
Field Value
DependencyProperty
DateSelectorOrderProperty
Identifies the DateSelectorOrder dependency property.
Declaration
public static readonly DependencyProperty DateSelectorOrderProperty
Field Value
DependencyProperty
DisplayModeProperty
Identifies the DisplayMode dependency property.
Declaration
public static readonly DependencyProperty DisplayModeProperty
Field Value
DependencyProperty
DisplayValueFormatProperty
Identifies the DisplayValueFormat dependency property.
Declaration
public static readonly DependencyProperty DisplayValueFormatProperty
Field Value
DependencyProperty
EmptyContentProperty
Identifies the EmptyContent dependency property.
Declaration
public static readonly DependencyProperty EmptyContentProperty
Field Value
DependencyProperty
EmptyContentTemplateProperty
Identifies the EmptyContentTemplateProperty.
Declaration
public static readonly DependencyProperty EmptyContentTemplateProperty
Field Value
DependencyProperty
IsOpenProperty
Identifies the IsOpen dependency property.
Declaration
public static readonly DependencyProperty IsOpenProperty
Field Value
DependencyProperty
IsReadOnlyProperty
Identifies the IsReadOnly dependency property.
Declaration
public static readonly DependencyProperty IsReadOnlyProperty
Field Value
DependencyProperty
ItemCountProperty
Identifies the ItemCount property.
Declaration
public static readonly DependencyProperty ItemCountProperty
Field Value
DependencyProperty
ItemHeightProperty
Identifies the ItemHeight property.
Declaration
public static readonly DependencyProperty ItemHeightProperty
Field Value
DependencyProperty
ItemSpacingProperty
Identifies the ItemSpacing property.
Declaration
public static readonly DependencyProperty ItemSpacingProperty
Field Value
DependencyProperty
ItemWidthProperty
Identifies the ItemWidth property.
Declaration
public static readonly DependencyProperty ItemWidthProperty
Field Value
DependencyProperty
MaxValueProperty
Identifies the MaxValue dependency property.
Declaration
public static readonly DependencyProperty MaxValueProperty
Field Value
DependencyProperty
MinValueProperty
Identifies the MinValue dependency property.
Declaration
public static readonly DependencyProperty MinValueProperty
Field Value
DependencyProperty
SelectorBackgroundStyleProperty
Identifies the SelectorBackgroundStyle dependency property.
Declaration
public static readonly DependencyProperty SelectorBackgroundStyleProperty
Field Value
DependencyProperty
SelectorDefaultValueProperty
Identifies the SelectorDefaultValue dependency property.
Declaration
public static readonly DependencyProperty SelectorDefaultValueProperty
Field Value
DependencyProperty
SelectorHeaderProperty
Identifies the SelectorHeader dependency property.
Declaration
public static readonly DependencyProperty SelectorHeaderProperty
Field Value
DependencyProperty
SelectorHeaderTemplateProperty
Identifies the SelectorHeaderTemplate dependency property.
Declaration
public static readonly DependencyProperty SelectorHeaderTemplateProperty
Field Value
DependencyProperty
StepProperty
Identifies the Step dependency property.
Declaration
public static readonly DependencyProperty StepProperty
Field Value
DependencyProperty
TimeSelectorOrderProperty
Identifies the TimeSelectorOrder dependency property.
Declaration
public static readonly DependencyProperty TimeSelectorOrderProperty
Field Value
DependencyProperty
ValueProperty
Identifies the Value dependency property.
Declaration
public static readonly DependencyProperty ValueProperty
Field Value
DependencyProperty
ValueStringProperty
Identifies the ValueString dependency property.
Declaration
public static readonly DependencyProperty ValueStringProperty
Field Value
DependencyProperty
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
public bool AutoSizeWidth { get; set; }
Property Value
Default value: true
Example
<telerikInput:RadDatePicker x:Name="datePicker" AutoSizeWidth="False"/>
datePicker.AutoSizeWidth = false;
CalendarIdentifier
Gets or sets the calendar identifier. The default value is .
CalendarLanguage
Gets or sets the calendar language. The default value is .
CalendarNumeralSystem
Gets or sets the calendar numeral system. The default value is .
Declaration
public string CalendarNumeralSystem { get; set; }
Property Value
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
public string DateSelectorOrder { get; set; }
Property Value
Options available for RadDatePicker: "y" (year), "m" (month), "d" (day)
Example
<telerikInput:RadDatePicker x:Name="datePicker" DateSelectorOrder="ym"/>
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
public DateTimePickerDisplayMode DisplayMode { get; set; }
Property Value
Example
<telerikInput:RadDatePicker x:Name="datePicker" DisplayMode="Standard"/>
datePicker.DisplayMode = DateTimePickerDisplayMode.Standard;
DisplayValueFormat
Gets or sets the format for the string being displayed The default value is Empty.
Declaration
public string DisplayValueFormat { get; set; }
Property Value
Example
<telerikInput:RadDatePicker x:Name="datePicker" DisplayValueFormat="dd-MM-yyyy"/>
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
public object EmptyContent { get; set; }
Property Value
Example
<telerikInput:RadDatePicker x:Name="datePicker" EmptyContent="No date is selected."/>
datePicker.EmptyContent = "No date is selected.";
EmptyContentTemplate
Gets or sets the DataTemplate defining the visual appearance of the empty content of the control.
Declaration
public DataTemplate EmptyContentTemplate { get; set; }
Property Value
DataTemplate
The empty content DataTemplate.
Example
<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
public bool IsOpen { get; set; }
Property Value
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
public bool IsReadOnly { get; set; }
Property Value
Default value: false.
Example
<telerikInput:RadDatePicker x:Name="datePicker" IsReadOnly="True"/>
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
public int ItemCount { get; set; }
Property Value
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
<telerikInput:RadDatePicker x:Name="datePicker" ItemCount="8"/>
datePicker.ItemCount = 8;
ItemHeight
Gets or sets the height of the DateTimeItem that appear in the selector part of the picker.
Declaration
public double ItemHeight { get; set; }
Property Value
Example
<telerikInput:RadDateTimePicker x:Name="dateTimePicker" ItemHeight="50"/>
dateTimePicker.ItemHeight = 50;
ItemSpacing
Gets or sets the margin of the DateTimeItem that appear in the selector part of the DateTimePicker.
Declaration
public double ItemSpacing { get; set; }
Property Value
Default value: 5.
Example
<telerikInput:RadDatePicker x:Name="datePicker" ItemSpacing="15"/>
datePicker.ItemSpacing = 15;
ItemWidth
Gets or sets the width of the DateTimeItem that appear in the selector part of the picker.
Declaration
public double ItemWidth { get; set; }
Property Value
Example
<telerikInput:RadDatePicker x:Name="datePicker" ItemWidth="100"/>
datePicker.ItemWidth = 100;
MaxValue
Gets or sets the maximum value of the Value property range for the control.
Declaration
public DateTime MaxValue { get; set; }
Property Value
Example
<telerikInput:RadDatePicker x:Name="datePicker"/>
datePicker.MaxValue = new DateTime(2014, 1, 1);
MinValue
Gets or sets the minimum value of the Value property range for the control.
Declaration
public DateTime MinValue { get; set; }
Property Value
Example
<telerikInput:RadDatePicker x:Name="datePicker"/>
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
public Style SelectorBackgroundStyle { get; set; }
Property Value
Style
Example
<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
public DateTime? SelectorDefaultValue { get; set; }
Property Value
Example
<telerikInput:RadDatePicker x:Name="datePicker" />
datePicker.SelectorDefaultValue = new DateTime(2021, 10, 11);
SelectorHeader
Gets or sets the header displayed in the selector part of the DateTimePicker instance.
Declaration
public object SelectorHeader { get; set; }
Property Value
Default value: null
Remarks
If the value is null, the default displayed text is "Select Date"/"Select Time"
for RadDatePicker/RadTimePicker.
Example
<telerikInput:RadDatePicker x:Name="datePicker" SelectorHeader="Enter your birthday"/>
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
public DataTemplate SelectorHeaderTemplate { get; set; }
Property Value
DataTemplate
Example
<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
public DateTimePickerStep Step { get; set; }
Property Value
Value
Gets or sets the date value.
Declaration
public DateTime? Value { get; set; }
Property Value
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
<telerikInput:RadDatePicker x:Name="datePicker"/>
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
public string ValueString { get; }
Property Value
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
<telerikInput:RadDatePicker x:Name="datePicker"/>
datePicker.Value = new DateTime(2022,1,1);
string date = datePicker.ValueString;// "1/1/2022"
Methods
ApplyTemplateCore()
Resolves the control's template parts.
GetValueStringFromCalendar(Calendar)
Gets the string that represents the Value according to the calendar.
Override this method to change the default ValueString.
Declaration
protected virtual string GetValueStringFromCalendar(Calendar calendar)
Parameters
calendar
Calendar
Returns
MeasureOverride(Size)
Provides the behavior for the Measure pass of the layout cycle.
Declaration
protected override Size MeasureOverride(Size availableSize)
Parameters
availableSize
Size
Returns
Size
Overrides
OnCreateAutomationPeer()
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
AutomationPeer
Overrides
OnKeyDown(KeyRoutedEventArgs)
Called before the KeyDown event occurs.
Declaration
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
protected override void OnTemplateApplied()
Overrides
UnapplyTemplateCore()
Removes the current control template. Occurs when a template has already been applied and a new one is applied.
Declaration
protected override void UnapplyTemplateCore()
Overrides
UnloadCore()
Called within the handler of the event. Allows inheritors to provide their specific logic.
Declaration
protected override void UnloadCore()
Overrides
Events
Closed
This event is raised when the selector part of the DateTimePicker control has been closed.
Opened
This event is raised when the selector part of the DateTimePicker control has been opened.
ValueChanged
This event is raised when the Value property has changed.