menu

MAUI Toolkit

  • User Guide
  • Demos
  • Support
Class SfDateTimePicker - MAUI-ToolKit API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfDateTimePicker

    Initializes a new instance of the SfDateTimePicker class that represents a control, used to select the date with in specified date range.

    Inheritance
    System.Object
    SfView
    PickerBase
    SfDateTimePicker
    Implements
    IDrawableLayout
    Microsoft.Maui.Graphics.IDrawable
    Microsoft.Maui.IAbsoluteLayout
    Microsoft.Maui.ILayout
    Microsoft.Maui.IView
    Microsoft.Maui.IElement
    Microsoft.Maui.ITransform
    Microsoft.Maui.IContainer
    System.Collections.Generic.IList<Microsoft.Maui.IView>
    System.Collections.Generic.ICollection<Microsoft.Maui.IView>
    System.Collections.Generic.IEnumerable<Microsoft.Maui.IView>
    System.Collections.IEnumerable
    Microsoft.Maui.ISafeAreaView
    Microsoft.Maui.IPadding
    Microsoft.Maui.ICrossPlatformLayout
    Microsoft.Maui.IVisualTreeElement
    Inherited Members
    PickerBase.AcceptCommand
    PickerBase.AcceptCommandProperty
    PickerBase.ArrangeContent(Rect)
    PickerBase.CancelButtonClicked
    PickerBase.Closed
    PickerBase.Closing
    PickerBase.ColumnDividerColor
    PickerBase.ColumnDividerColorProperty
    PickerBase.ColumnHeaderTemplate
    PickerBase.ColumnHeaderTemplateProperty
    PickerBase.DeclineCommand
    PickerBase.DeclineCommandProperty
    PickerBase.EnableLooping
    PickerBase.EnableLoopingProperty
    PickerBase.FooterTemplate
    PickerBase.FooterTemplateProperty
    PickerBase.FooterView
    PickerBase.FooterViewProperty
    PickerBase.HeaderTemplate
    PickerBase.HeaderTemplateProperty
    PickerBase.IsOpen
    PickerBase.IsOpenProperty
    PickerBase.ItemHeight
    PickerBase.ItemHeightProperty
    PickerBase.MeasureContent(Double, Double)
    PickerBase.Mode
    PickerBase.ModeProperty
    PickerBase.OkButtonClicked
    PickerBase.OnPropertyChanged(String)
    PickerBase.Opened
    PickerBase.PopupHeight
    PickerBase.PopupHeightProperty
    PickerBase.PopupWidth
    PickerBase.PopupWidthProperty
    PickerBase.RelativePosition
    PickerBase.RelativePositionProperty
    PickerBase.RelativeView
    PickerBase.RelativeViewProperty
    PickerBase.SelectedTextStyle
    PickerBase.SelectedTextStyleProperty
    PickerBase.SelectionView
    PickerBase.SelectionViewProperty
    PickerBase.TextDisplayMode
    PickerBase.TextDisplayModeProperty
    PickerBase.TextStyle
    PickerBase.TextStyleProperty
    SfView.Children
    SfView.ClipToBounds
    SfView.Padding
    Namespace: Syncfusion.Maui.Toolkit.Picker
    Assembly: Syncfusion.Maui.Toolkit.dll
    Syntax
    public class SfDateTimePicker : 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

    SfDateTimePicker()

    Initializes a new instance of the SfDateTimePicker class.

    Declaration
    public SfDateTimePicker()

    Fields

    BlackoutDateTimesProperty

    Identifies the BlackoutDateTimes dependency property.

    Declaration
    public static readonly BindableProperty BlackoutDateTimesProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for BlackoutDateTimes 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.

    DateFormatProperty

    Identifies the DateFormat dependency property.

    Declaration
    public static readonly BindableProperty DateFormatProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for DateFormat 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.

    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.

    HourIntervalProperty

    Identifies the HourInterval dependency property.

    Declaration
    public static readonly BindableProperty HourIntervalProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for HourInterval 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.

    MinuteIntervalProperty

    Identifies the MinuteInterval dependency property.

    Declaration
    public static readonly BindableProperty MinuteIntervalProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for MinuteInterval 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.

    SecondIntervalProperty

    Identifies the SecondInterval dependency property.

    Declaration
    public static readonly BindableProperty SecondIntervalProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for SecondInterval 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.

    TimeFormatProperty

    Identifies the TimeFormat dependency property.

    Declaration
    public static readonly BindableProperty TimeFormatProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for TimeFormat 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

    BlackoutDateTimes

    Gets or sets the BlackoutDateTimes in SfDateTimePicker.

    Declaration
    public ObservableCollection<DateTime> BlackoutDateTimes { get; set; }
    Property Value
    Type
    System.Collections.ObjectModel.ObservableCollection<System.DateTime>
    Remarks

    The selection view will not be applicable when setting blackout datetimes.

    Examples

    The following examples demonstrate how to set the blackout date times in SfDateTimePicker.

    • XAML
    • C#
    <picker:SfDateTimePicker x:Name="picker">
       <picker:SfDateTimePicker.BlackoutDateTimes>
          <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-15 12:11:00</date:DateTime>
          <date:DateTime>2001-08-15 12:12:00</date:DateTime>
          <date:DateTime>2001-08-15 12:08:00</date:DateTime>
          <date:DateTime>2001-08-15 12:06:00</date:DateTime>
       </picker:SfDateTimePicker.BlackoutDateTimes>
    </picker:SfDateTimePicker>
    SfDatePicker picker = new SfDatePicker();
    picker.BlackoutDateTimes.Add(new DateTime(2001, 8, 10));
    picker.BlackoutDateTimes.Add(new DateTime(2001, 8, 12));
    picker.BlackoutDateTimes.Add(new DateTime(2001, 8, 14));
    picker.BlackoutDateTimes.Add(new DateTime(2001, 8, 17));
    picker.BlackoutDateTimes.Add(new DateTime(2001, 8, 15, 12, 11, 0));
    picker.BlackoutDateTimes.Add(new DateTime(2001, 8, 15, 12, 12, 0));
    picker.BlackoutDateTimes.Add(new DateTime(2001, 8, 15, 12, 8, 0));

    ColumnHeaderView

    Gets or sets the value of column header view. This property can be used to customize the header column in SfDateTimePicker.

    Declaration
    public DateTimePickerColumnHeaderView ColumnHeaderView { get; set; }
    Property Value
    Type
    DateTimePickerColumnHeaderView
    Examples

    The following example demonstrates how to customize the column header view of SfDateTimePicker.

    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.ColumnHeaderView = new DateTimePickerColumnHeaderView
    {
        Background = new SolidColorBrush(Colors.LightBlue),
        Height = 40,
        DividerColor = Colors.Gray,
        TextStyle = new PickerTextStyle
        {
            TextColor = Colors.DarkBlue,
            FontSize = 16
        },
    };

    DateFormat

    Gets or sets the picker date format in SfDateTimePicker.

    Declaration
    public PickerDateFormat DateFormat { get; set; }
    Property Value
    Type Description
    PickerDateFormat

    The default value of DateFormat is yyyy_MM_dd.

    Examples

    The following examples demonstrate how to set the date format in SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                             DateFormat="dd_MM_yyyy" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.DateFormat = PickerDateFormat.dd_MM_yyyy;

    DayInterval

    Gets or sets the day interval in SfDateTimePicker.

    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 SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                         DayInterval="2" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.DayInterval = 2;

    HeaderView

    Gets or sets the value of header view. This property can be used to customize the header in SfDateTimePicker.

    Declaration
    public DateTimePickerHeaderView HeaderView { get; set; }
    Property Value
    Type
    DateTimePickerHeaderView
    Examples

    The following example demonstrates how to customize the header view of SfDateTimePicker.

    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.HeaderView = new DateTimePickerHeaderView
    {
        TextStyle = new PickerTextStyle
        {
            TextColor = Colors.Blue,
            FontSize = 18,
            FontAttributes = FontAttributes.Bold
        },
        Background = new SolidColorBrush(Colors.LightGray)
    };

    HourInterval

    Gets or sets the hour interval in SfDateTimePicker.

    Declaration
    public int HourInterval { get; set; }
    Property Value
    Type Description
    System.Int32

    The default value of HourInterval is 1.

    Examples

    The following examples demonstrate how to set the hour interval in SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                         HourInterval="2" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.HourInterval = 2;

    MaximumDate

    Gets or sets the maximum date in SfDateTimePicker.

    Declaration
    public DateTime MaximumDate { get; set; }
    Property Value
    Type Description
    System.DateTime

    The default value of MaximumDate is "DateTime(2100, 12, 31, 23, 59, 59)".

    Examples

    The following examples demonstrate how to set the maximum date in SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                             MaximumDate="2023-12-31 23:59:59" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.MaximumDate = new DateTime(2023, 12, 31, 23, 59, 59);

    MinimumDate

    Gets or sets the minimum date in SfDateTimePicker.

    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 SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                             MinimumDate="2023-01-01" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.MinimumDate = new DateTime(2023, 1, 1);

    MinuteInterval

    Gets or sets the minute interval in SfDateTimePicker.

    Declaration
    public int MinuteInterval { get; set; }
    Property Value
    Type Description
    System.Int32

    The default value of MinuteInterval is 1.

    Examples

    The following examples demonstrate how to set the minute interval in SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                         MinuteInterval="2" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.MinuteInterval = 2;

    MonthInterval

    Gets or sets the month interval in SfDateTimePicker.

    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 SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                         MonthInterval="2" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.MonthInterval = 2;

    SecondInterval

    Gets or sets the second interval in SfDateTimePicker.

    Declaration
    public int SecondInterval { get; set; }
    Property Value
    Type Description
    System.Int32

    The default value of SecondInterval is 1.

    Examples

    The following examples demonstrate how to set the second interval in SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                         SecondInterval="2" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.SecondInterval = 2;

    SelectedDate

    Gets or sets the date picker selected date in SfDateTimePicker.

    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 SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                             SelectedDate="2023-06-15 14:30:00" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.SelectedDate = new DateTime(2023, 6, 15, 14, 30, 0);

    SelectionChangedCommand

    Gets or sets the selection changed command in SfDateTimePicker.

    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 SfDateTimePicker.

    • XAML
    • C#
    <ContentPage.BindingContext>
       <local:ViewModel/>
    </ContentPage.BindingContext>
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                         SelectionChangedCommand="{Binding SelectionCommand}">
    </Picker:SfDateTimePicker>
    public class ViewModel : INotifyPropertyChanged
    {
       private Command selectionCommand;
       public ICommand SelectionCommand {
           get
           {
               return selectionCommand;
           }
           set
           {
               if (selectionCommand != value)
               {
                   selectionCommand = value;
                   OnPropertyChanged(nameof(SelectionCommand));
               }
           }
       }
       public ViewModel()
       {
         SelectionCommand = new Command(SelectionChanged);
       }
       private void SelectionChanged()
       {
       }
     }

    TimeFormat

    Gets or sets the picker time format in SfDateTimePicker.

    Declaration
    public PickerTimeFormat TimeFormat { get; set; }
    Property Value
    Type Description
    PickerTimeFormat

    The default value of TimeFormat is HH_mm_ss.

    Examples

    The following examples demonstrate how to set the time format in SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                             TimeFormat="hh_mm_tt" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.TimeFormat = PickerTimeFormat.hh_mm_tt;

    YearInterval

    Gets or sets the year interval in SfDateTimePicker.

    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 SfDateTimePicker.

    • XAML
    • C#
    <Picker:SfDateTimePicker x:Name="DateTimePicker"
                         YearInterval="2" />
    SfDateTimePicker dateTimePicker = new SfDateTimePicker();
    dateTimePicker.YearInterval = 2;

    Methods

    Initialize()

    Method to wire the events.

    Declaration
    protected override void Initialize()
    Overrides
    PickerBase.Initialize()

    OnBindingContextChanged()

    Method triggers when the property binding context changed.

    Declaration
    protected override void OnBindingContextChanged()
    Overrides
    Syncfusion.Maui.Toolkit.SfView.OnBindingContextChanged()

    OnCancelButtonClicked(EventArgs)

    Method triggers when the date time picker cancel button clicked.

    Declaration
    protected override void OnCancelButtonClicked(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The event arguments.

    Overrides
    PickerBase.OnCancelButtonClicked(EventArgs)

    OnHeaderButtonClicked(Int32)

    Method triggers while the header button clicked.

    Declaration
    protected override void OnHeaderButtonClicked(int index)
    Parameters
    Type Name Description
    System.Int32 index

    Index of the header button.

    Overrides
    PickerBase.OnHeaderButtonClicked(Int32)

    OnOkButtonClicked(EventArgs)

    Method triggers when the date time picker ok button clicked.

    Declaration
    protected override void OnOkButtonClicked(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The event arguments.

    Overrides
    PickerBase.OnOkButtonClicked(EventArgs)

    OnPickerLoading()

    Method triggers while the popup opening or switched from popup to default.

    Declaration
    protected override void OnPickerLoading()
    Overrides
    PickerBase.OnPickerLoading()

    OnPopupClosed(EventArgs)

    Method triggers when the date time picker popup closed.

    Declaration
    protected override void OnPopupClosed(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The event arguments.

    Overrides
    PickerBase.OnPopupClosed(EventArgs)

    OnPopupClosing(CancelEventArgs)

    Method triggers when the date time picker popup closing.

    Declaration
    protected override void OnPopupClosing(CancelEventArgs e)
    Parameters
    Type Name Description
    System.ComponentModel.CancelEventArgs e

    The event arguments.

    Overrides
    PickerBase.OnPopupClosing(CancelEventArgs)

    OnPopupOpened(EventArgs)

    Method triggers when the date time picker popup opened.

    Declaration
    protected override void OnPopupOpened(EventArgs e)
    Parameters
    Type Name Description
    System.EventArgs e

    The event arguments.

    Overrides
    PickerBase.OnPopupOpened(EventArgs)

    Events

    SelectionChanged

    Occurs after the selected date is changed on SfDateTimePicker.

    Declaration
    public event EventHandler<DateTimePickerSelectionChangedEventArgs> SelectionChanged
    Event Type
    Type
    System.EventHandler<DateTimePickerSelectionChangedEventArgs>

    Implements

    IDrawableLayout
    Microsoft.Maui.Graphics.IDrawable
    Microsoft.Maui.IAbsoluteLayout
    Microsoft.Maui.ILayout
    Microsoft.Maui.IView
    Microsoft.Maui.IElement
    Microsoft.Maui.ITransform
    Microsoft.Maui.IContainer
    System.Collections.Generic.IList<>
    System.Collections.Generic.ICollection<>
    System.Collections.Generic.IEnumerable<>
    System.Collections.IEnumerable
    Microsoft.Maui.ISafeAreaView
    Microsoft.Maui.IPadding
    Microsoft.Maui.ICrossPlatformLayout
    Microsoft.Maui.IVisualTreeElement
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved