Class DatePicker
A control to allow the user to select a date
[TemplatePart("PART_ButtonContentGrid", typeof(Grid))]
[TemplatePart("PART_DayTextBlock", typeof(TextBlock))]
[TemplatePart("PART_FirstSpacer", typeof(Rectangle))]
[TemplatePart("PART_FlyoutButton", typeof(Button))]
[TemplatePart("PART_MonthTextBlock", typeof(TextBlock))]
[TemplatePart("PART_PickerPresenter", typeof(DatePickerPresenter))]
[TemplatePart("PART_Popup", typeof(Popup))]
[TemplatePart("PART_SecondSpacer", typeof(Rectangle))]
[TemplatePart("PART_YearTextBlock", typeof(TextBlock))]
[PseudoClasses(new string[] { ":hasnodate" })]
public class DatePicker : TemplatedControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
- Inheritance
-
DatePicker
- Implements
- Inherited Members
- Extension Methods
Constructors
DatePicker()
public DatePicker()
Fields
DayFormatProperty
Define the DayFormat Property
public static readonly StyledProperty<string> DayFormatProperty
Field Value
DayVisibleProperty
Defines the DayVisible Property
public static readonly StyledProperty<bool> DayVisibleProperty
Field Value
MaxYearProperty
Defines the MaxYear Property
public static readonly StyledProperty<DateTimeOffset> MaxYearProperty
Field Value
MinYearProperty
Defines the MinYear Property
public static readonly StyledProperty<DateTimeOffset> MinYearProperty
Field Value
MonthFormatProperty
Defines the MonthFormat Property
public static readonly StyledProperty<string> MonthFormatProperty
Field Value
MonthVisibleProperty
Defines the MonthVisible Property
public static readonly StyledProperty<bool> MonthVisibleProperty
Field Value
SelectedDateProperty
Defines the SelectedDate Property
public static readonly StyledProperty<DateTimeOffset?> SelectedDateProperty
Field Value
YearFormatProperty
Defines the YearFormat Property
public static readonly StyledProperty<string> YearFormatProperty
Field Value
YearVisibleProperty
Defines the YearVisible Property
public static readonly StyledProperty<bool> YearVisibleProperty
Field Value
Properties
DayFormat
public string DayFormat { get; set; }
Property Value
DayVisible
Gets or sets whether the day is visible
public bool DayVisible { get; set; }
Property Value
MaxYear
Gets or sets the maximum year for the picker
public DateTimeOffset MaxYear { get; set; }
Property Value
MinYear
Gets or sets the minimum year for the picker
public DateTimeOffset MinYear { get; set; }
Property Value
MonthFormat
Gets or sets the month format
public string MonthFormat { get; set; }
Property Value
MonthVisible
Gets or sets whether the month is visible
public bool MonthVisible { get; set; }
Property Value
SelectedDate
Gets or sets the Selected Date for the picker, can be null
public DateTimeOffset? SelectedDate { get; set; }
Property Value
YearFormat
Gets or sets the year format
public string YearFormat { get; set; }
Property Value
YearVisible
Gets or sets whether the year is visible
public bool YearVisible { get; set; }
Property Value
Methods
Clear()
Clear SelectedDate.
public void Clear()
OnApplyTemplate(TemplateAppliedEventArgs)
Called when the control's template is applied. In simple terms, this means the method is called just before the control is displayed.
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
Parameters
e
TemplateAppliedEventArgsThe event args.
OnCreateAutomationPeer()
Returns a new, type-specific AutomationPeer implementation for the control.
protected override AutomationPeer OnCreateAutomationPeer()
Returns
- AutomationPeer
The type-specific AutomationPeer implementation.
OnPropertyChanged(AvaloniaPropertyChangedEventArgs)
Called when a avalonia property changes on the object.
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
Parameters
change
AvaloniaPropertyChangedEventArgsThe property change details.
OnSelectedDateChanged(object?, DatePickerSelectedValueChangedEventArgs)
protected virtual void OnSelectedDateChanged(object? sender, DatePickerSelectedValueChangedEventArgs e)
Parameters
UpdateDataValidation(AvaloniaProperty, BindingValueType, Exception?)
Called to update the validation state for properties for which data validation is enabled.
protected override void UpdateDataValidation(AvaloniaProperty property, BindingValueType state, Exception? error)
Parameters
property
AvaloniaPropertyThe property.
state
BindingValueTypeThe current data binding state.
error
ExceptionThe current data binding error, if any.
Events
SelectedDateChanged
Raised when the SelectedDate changes
public event EventHandler<DatePickerSelectedValueChangedEventArgs>? SelectedDateChanged