Class DatePicker
Represents a control that allows the user to select a date.
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.Controls.dll
Syntax
[TemplatePart(Name = "Root", Type = typeof(FrameworkElement))]
[TemplatePart(Name = "TextBox", Type = typeof(DatePickerTextBox))]
[TemplatePart(Name = "Button", Type = typeof(Button))]
[TemplatePart(Name = "Popup", Type = typeof(Popup))]
[StyleTypedProperty(Property = "CalendarStyle", StyleTargetType = typeof(Calendar))]
public class DatePicker : Control, IControl, IFrameworkElement, IUIElement, IDependencyObject
Constructors
| Improve this Doc View SourceDatePicker()
Initializes a new instance of the DatePicker class.
Declaration
public DatePicker()
Fields
| Improve this Doc View SourceCalendarStyleProperty
Identifies the CalendarStyle dependency property.
Declaration
public static readonly DependencyProperty CalendarStyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the CalendarStyle dependency property. |
DisplayDateEndProperty
Identifies the DisplayDateEnd dependency property.
Declaration
public static readonly DependencyProperty DisplayDateEndProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the DisplayDateEnd dependency property. |
DisplayDateProperty
Identifies the DisplayDate dependency property.
Declaration
public static readonly DependencyProperty DisplayDateProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the DisplayDate dependency property. |
DisplayDateStartProperty
Identifies the DisplayDateStart dependency property.
Declaration
public static readonly DependencyProperty DisplayDateStartProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the DisplayDateStart dependency property. |
FirstDayOfWeekProperty
Identifies the FirstDayOfWeek dependency property.
Declaration
public static readonly DependencyProperty FirstDayOfWeekProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the FirstDayOfWeek dependency property. |
IsDropDownOpenProperty
Identifies the IsDropDownOpen dependency property.
Declaration
public static readonly DependencyProperty IsDropDownOpenProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the IsDropDownOpen dependency property. |
IsTodayHighlightedProperty
Identifies the IsTodayHighlighted dependency property.
Declaration
public static readonly DependencyProperty IsTodayHighlightedProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the IsTodayHighlighted dependency property. |
SelectedDateFormatProperty
Identifies the SelectedDateFormat dependency property.
Declaration
public static readonly DependencyProperty SelectedDateFormatProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the SelectedDateFormat dependency property. |
SelectedDateProperty
Identifies the SelectedDate dependency property.
Declaration
public static readonly DependencyProperty SelectedDateProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the SelectedDate dependency property. |
SelectionBackgroundProperty
Identifies the SelectionBackground dependency property.
Declaration
public static readonly DependencyProperty SelectionBackgroundProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the SelectionBackground dependency property. |
TextProperty
Identifies the Text dependency property.
Declaration
public static readonly DependencyProperty TextProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the Text dependency property. |
Properties
| Improve this Doc View SourceBlackoutDates
Gets a collection of dates that are marked as not selectable.
Declaration
public CalendarBlackoutDatesCollection BlackoutDates { get; }
Property Value
Type | Description |
---|---|
CalendarBlackoutDatesCollection | A collection of dates that cannot be selected. The default value is an empty collection. |
CalendarStyle
Gets or sets the style that is used when rendering the calendar.
Declaration
public Style CalendarStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The style that is used when rendering the calendar. |
DisplayDate
Gets or sets the date to display.
Declaration
[TypeConverter(typeof(DateTimeTypeConverter))]
public DateTime DisplayDate { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime | The date to display. The default System.DateTime.Today. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The specified date is not in the range defined by DisplayDateStart and DisplayDateEnd. |
DisplayDateEnd
Gets or sets the last date to be displayed.
Declaration
[TypeConverter(typeof(DateTimeTypeConverter))]
public DateTime? DisplayDateEnd { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | The last date to display. |
DisplayDateStart
Gets or sets the first date to be displayed.
Declaration
[TypeConverter(typeof(DateTimeTypeConverter))]
public DateTime? DisplayDateStart { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | The first date to display. |
FirstDayOfWeek
Gets or sets the day that is considered the beginning of the week.
Declaration
public DayOfWeek FirstDayOfWeek { get; set; }
Property Value
Type | Description |
---|---|
System.DayOfWeek | A System.DayOfWeek representing the beginning of the week. The default is System.DayOfWeek.Sunday. |
IsDropDownOpen
Gets or sets a value indicating whether the drop-down Calendar is open or closed.
Declaration
public bool IsDropDownOpen { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the Calendar is open; otherwise, false. The default is false. |
IsTodayHighlighted
Gets or sets a value indicating whether the current date will be highlighted.
Declaration
public bool IsTodayHighlighted { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the current date is highlighted; otherwise, false. The default is true. |
SelectedDate
Gets or sets the currently selected date.
Declaration
[TypeConverter(typeof(DateTimeTypeConverter))]
public DateTime? SelectedDate { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | The date currently selected. The default is null. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The specified date is not in the range defined by DisplayDateStart and DisplayDateEnd, or the specified date is in the BlackoutDates collection. |
SelectedDateFormat
Gets or sets the format that is used to display the selected date.
Declaration
public DatePickerFormat SelectedDateFormat { get; set; }
Property Value
Type | Description |
---|---|
DatePickerFormat | The format that is used to display the selected date. The default is Short. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | An specified format is not valid. |
SelectionBackground
Gets or sets the background used for selected dates.
Declaration
public Brush SelectionBackground { get; set; }
Property Value
Type | Description |
---|---|
Brush | The background used for selected dates. |
Text
Gets or sets the text that is displayed by the DatePicker.
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | The text displayed by the DatePicker. |
Exceptions
Type | Condition |
---|---|
System.FormatException | The text entered cannot be parsed to a valid date, and the exception is not suppressed. |
System.ArgumentOutOfRangeException | The text entered parses to a date that is not selectable. |
Methods
| Improve this Doc View SourceOnApplyTemplate()
Builds the visual tree for the DatePicker control when a new template is applied.
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnCreateAutomationPeer()
Returns a DatePickerAutomationPeer for use by the Silverlight automation infrastructure.
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type | Description |
---|---|
AutomationPeer | A DatePickerAutomationPeer for the DatePicker object. |
Overrides
| Improve this Doc View SourceOnDateValidationError(DatePickerDateValidationErrorEventArgs)
Raises the DateValidationError event.
Declaration
protected virtual void OnDateValidationError(DatePickerDateValidationErrorEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DatePickerDateValidationErrorEventArgs | e | A DatePickerDateValidationErrorEventArgs that contains the event data. |
OnMouseWheel(MouseWheelEventArgs)
Default mouse wheel handler for the DatePicker control.
Declaration
protected override void OnMouseWheel(MouseWheelEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseWheelEventArgs | e | Mouse wheel event args. |
Overrides
| Improve this Doc View SourceToString()
Provides a text representation of the selected date.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A text representation of the selected date, or an empty string if SelectedDate is a null reference. |
Overrides
Events
| Improve this Doc View SourceCalendarClosed
Occurs when the drop-down Calendar is closed.
Declaration
public event RoutedEventHandler CalendarClosed
Event Type
Type | Description |
---|---|
RoutedEventHandler |
CalendarOpened
Occurs when the drop-down Calendar is opened.
Declaration
public event RoutedEventHandler CalendarOpened
Event Type
Type | Description |
---|---|
RoutedEventHandler |
DateValidationError
Occurs when Text is assigned a value that cannot be interpreted as a date.
Declaration
public event EventHandler<DatePickerDateValidationErrorEventArgs> DateValidationError
Event Type
Type | Description |
---|---|
System.EventHandler<DatePickerDateValidationErrorEventArgs> |
SelectedDateChanged
Occurs when the SelectedDate property is changed.
Declaration
public event EventHandler<SelectionChangedEventArgs> SelectedDateChanged
Event Type
Type | Description |
---|---|
System.EventHandler<SelectionChangedEventArgs> |