Class SfDatePicker
Initializes a new instance of the SfDatePicker class that represents a control, used to select the date with in specified date range.
Implements
Inherited Members
Namespace: Syncfusion.Maui.Toolkit.Picker
Assembly: Syncfusion.Maui.Toolkit.dll
Syntax
public class SfDatePicker : PickerBase, IDrawableLayout, IDrawable, IAbsoluteLayout, ILayout, IView, IElement, ITransform, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISafeAreaView, IPadding, ICrossPlatformLayout, IVisualTreeElement, ISemanticsProvider, IPicker, IPickerView, IColumnHeaderView, IFooterView, IHeaderView, IPickerCommon, IParentThemeElement, IThemeElement
Constructors
SfDatePicker()
Initializes a new instance of the SfDatePicker class.
Declaration
public SfDatePicker()
Fields
BlackoutDatesProperty
Identifies the BlackoutDates dependency property.
Declaration
public static readonly BindableProperty BlackoutDatesProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for BlackoutDates dependency property. |
ColumnHeaderViewProperty
Identifies the ColumnHeaderView dependency property.
Declaration
public static readonly BindableProperty ColumnHeaderViewProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for ColumnHeaderView dependency property. |
DayIntervalProperty
Identifies the DayInterval dependency property.
Declaration
public static readonly BindableProperty DayIntervalProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for DayInterval dependency property. |
FormatProperty
Identifies the Format dependency property.
Declaration
public static readonly BindableProperty FormatProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for Format dependency property. |
HeaderViewProperty
Identifies the HeaderView dependency property.
Declaration
public static readonly BindableProperty HeaderViewProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for HeaderView dependency property. |
MaximumDateProperty
Identifies the MaximumDate dependency property.
Declaration
public static readonly BindableProperty MaximumDateProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for MaximumDate dependency property. |
MinimumDateProperty
Identifies the MinimumDate dependency property.
Declaration
public static readonly BindableProperty MinimumDateProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for MinimumDate dependency property. |
MonthIntervalProperty
Identifies the MonthInterval dependency property.
Declaration
public static readonly BindableProperty MonthIntervalProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for MonthInterval dependency property. |
SelectedDateProperty
Identifies the SelectedDate dependency property.
Declaration
public static readonly BindableProperty SelectedDateProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for SelectedDate dependency property. |
SelectionChangedCommandProperty
Identifies the SelectionChangedCommand dependency property.
Declaration
public static readonly BindableProperty SelectionChangedCommandProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for SelectionChangedCommand dependency property. |
YearIntervalProperty
Identifies the YearInterval dependency property.
Declaration
public static readonly BindableProperty YearIntervalProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty | The identifier for YearInterval dependency property. |
Properties
BlackoutDates
Gets or sets the BlackoutDates in SfDatePicker.
Declaration
public ObservableCollection<DateTime> BlackoutDates { get; set; }
Property Value
Type |
---|
System.Collections.ObjectModel.ObservableCollection<System.DateTime> |
Remarks
The selection view will not be applicable when setting blackout dates.
Examples
The following examples demonstrate how to set the blackout dates in SfDatePicker.
<picker:SfDatePicker x:Name="picker">
<picker:SfDatePicker.BlackoutDates>
<date:DateTime>2001-08-10</date:DateTime>
<date:DateTime>2001-08-12</date:DateTime>
<date:DateTime>2001-08-14</date:DateTime>
<date:DateTime>2001-08-17</date:DateTime>
<date:DateTime>2001-08-18</date:DateTime>
<date:DateTime>2001-08-20</date:DateTime>
</picker:SfDatePicker.BlackoutDates>
</picker:SfDatePicker>
ColumnHeaderView
Gets or sets the value of column header view. This property can be used to customize the header column in SfDatePicker.
Declaration
public DatePickerColumnHeaderView ColumnHeaderView { get; set; }
Property Value
Type |
---|
DatePickerColumnHeaderView |
Examples
The following example demonstrates how to customize the column header view of SfDatePicker.
SfDatePicker datePicker = new SfDatePicker();
datePicker.ColumnHeaderView = new DatePickerColumnHeaderView
{
Background = new SolidColorBrush(Colors.LightBlue),
Height = 40,
DividerColor = Colors.Gray,
TextStyle = new PickerTextStyle
{
TextColor = Colors.DarkBlue,
FontSize = 16
},
DayHeaderText = "Date",
MonthHeaderText = "Month",
YearHeaderText = "Year"
};
DayInterval
Gets or sets the day interval in SfDatePicker.
Declaration
public int DayInterval { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The default value of DayInterval is 1. |
Examples
The following examples demonstrate how to set the day interval in SfDatePicker.
Format
Gets or sets the picker date format in SfDatePicker.
Declaration
public PickerDateFormat Format { get; set; }
Property Value
Type | Description |
---|---|
PickerDateFormat | The default value of Format is yyyy_MM_dd. |
Examples
The following examples demonstrate how to set the format in SfDatePicker.
HeaderView
Gets or sets the value of header view. This property can be used to customize the header in SfDatePicker.
Declaration
public PickerHeaderView HeaderView { get; set; }
Property Value
Type |
---|
PickerHeaderView |
Examples
The following example demonstrates how to customize the header view of SfDatePicker.
SfDatePicker datePicker = new SfDatePicker();
datePicker.HeaderView = new PickerHeaderView
{
Text = "Select Date",
TextStyle = new PickerTextStyle
{
TextColor = Colors.Blue,
FontSize = 18,
FontAttributes = FontAttributes.Bold
},
Background = new SolidColorBrush(Colors.LightGray)
};
MaximumDate
Gets or sets the maximum date in SfDatePicker.
Declaration
public DateTime MaximumDate { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime | The default value of MaximumDate is "DateTime(2100, 12, 31)". |
Examples
The following examples demonstrate how to set the maximum date in SfDatePicker.
MinimumDate
Gets or sets the minimum date in SfDatePicker.
Declaration
public DateTime MinimumDate { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime | The default value of MinimumDate is "DateTime(1900, 01, 01)". |
Examples
The following examples demonstrate how to set the minimum date in SfDatePicker.
MonthInterval
Gets or sets the month interval in SfDatePicker.
Declaration
public int MonthInterval { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The default value of MonthInterval is 1. |
Examples
The following examples demonstrate how to set the month interval in SfDatePicker.
SelectedDate
Gets or sets the date picker selection date in SfDatePicker.
Declaration
public Nullable<DateTime> SelectedDate { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | The default value of SelectedDate is System.DateTime.Now. |
Examples
The following examples demonstrate how to set the selected date in SfDatePicker.
SelectionChangedCommand
Gets or sets the selection changed command in SfDatePicker.
Declaration
public ICommand SelectionChangedCommand { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand | The default value of SelectionChangedCommand is null. |
Examples
The following example demonstrates how to set the selection changed command in SfDatePicker.
<ContentPage.BindingContext>
<local:ViewModel/>
</ContentPage.BindingContext>
<Picker:SfDatePicker x:Name="DatePicker"
SelectionChangedCommand="{Binding SelectionCommand}">
</Picker:SfDatePicker>
YearInterval
Gets or sets the year interval in SfDatePicker.
Declaration
public int YearInterval { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The default value of YearInterval is 1. |
Examples
The following examples demonstrate how to set the year interval in SfDatePicker.
Methods
Initialize()
Method to wire the events.
Declaration
protected override void Initialize()
Overrides
OnBindingContextChanged()
Method triggers when the property binding context changed.
Declaration
protected override void OnBindingContextChanged()
Overrides
OnCancelButtonClicked(EventArgs)
Method triggers when clicked the date picker cancel button.
Declaration
protected override void OnCancelButtonClicked(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | The event arguments. |
Overrides
OnOkButtonClicked(EventArgs)
Method triggers when clicked the date picker ok button.
Declaration
protected override void OnOkButtonClicked(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | The event arguments |
Overrides
OnPopupClosed(EventArgs)
Method triggers when closed the date picker popup.
Declaration
protected override void OnPopupClosed(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | The event arguments. |
Overrides
OnPopupClosing(CancelEventArgs)
Method triggers when closing the date picker popup.
Declaration
protected override void OnPopupClosing(CancelEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.CancelEventArgs | e | The event arguments. |
Overrides
OnPopupOpened(EventArgs)
Method triggers when opened the date picker popup.
Declaration
protected override void OnPopupOpened(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | The event arguments. |
Overrides
Events
SelectionChanged
Occurs after the selected date is changed on SfDatePicker.
Declaration
public event EventHandler<DatePickerSelectionChangedEventArgs> SelectionChanged
Event Type
Type |
---|
System.EventHandler<DatePickerSelectionChangedEventArgs> |