Migrate from Xamarin.Forms SfDatePicker to .NET MAUI SfDatePicker

21 Aug 20246 minutes to read

To make the migration from the Xamarin SfDatePicker to .NET MAUI SfDatePicker easier, most of the APIs from the Xamarin SfDatePicker are kept in the .NET MAUI SfDatePicker. However, to maintain the consistency of API naming in the .NET MAUI SfDatePicker, some of the APIs have been renamed. Please find the difference in the following topics.

Namespaces

Xamarin SfDatePicker .NET MAUI SfDatePicker
Syncfusion.XForms.Pickers Syncfusion.Maui.Picker

Initialize control

To initialize the control, import the date picker namespace and initialize SfDatePicker as shown in the following code sample.

Xamarin SfDatePicker .NET MAUI SfDatePicker
<ContentPage
xmlns:datePicker="clr-namespace:Syncfusion.XForms.Pickers;assembly=Syncfusion.SfPicker.XForms">

    <datePicker:SfDatePicker />

</ContentPage>
using Syncfusion.XForms.Pickers;
...

SfDatePicker datePicker = new SfDatePicker();
this.Content = datePicker;
<ContentPage
xmlns:datePicker="clr-namespace:Syncfusion.Maui.Picker;assembly=Syncfusion.Maui.Picker">

    <datePicker:SfDatePicker />

</ContentPage>
using Syncfusion.Maui.Picker;
...

SfDatePicker datePicker = new SfDatePicker();
this.Content = datePicker;

Classes

Xamarin SfDatePicker .NET MAUI SfDatePicker Description

PickerBase

PickerBase

Represents a base used to achieve the date picker custom view.

DateChangedEventArgs

DatePickerSelectionChangedEventArgs

Represents a class which is used to hold the selection changed event details.

Properties

SfDatePicker

The following code example, explains how to initialize the properties of the Xamarin SfDatePicker and .NET MAUI SfDatePicker class.

Xamarin SfDatePicker .NET MAUI SfDatePicker
<ContentPage
xmlns:datePicker="clr-namespace:Syncfusion.XForms.Pickers;assembly=Syncfusion.SfPicker.XForms">
    
    <datePicker:SfDatePicker Format="yyyy_MM_dd"/>

</ContentPage>
using Syncfusion.SfPicker.XForms;
...

SfDatePicker datePicker = new SfDatePicker();
datePicker.Format = DateFormat.yyyy_MM_dd;
this.Content = datePicker;
<ContentPage
xmlns:datePicker="clr-namespace:Syncfusion.Maui.Picker;assembly=Syncfusion.Maui.Picker">

    <datePicker:SfDatePicker Format="MM_dd_yyyy"/>

</ContentPage>
using Syncfusion.Maui.Picker;
...

SfDatePicker datePicker = new SfDatePicker();
datePicker.Format = PickerDateFormat.MM_dd_yyyy;
this.Content = datePicker;
Xamarin SfDatePicker .NET MAUI SfDatePicker Description

CommandParameter

Nil Not Supported.

CancelCommand

DeclineCommand

Gets or sets a command to decline a selected date of SfDatePicker.

Date

SelectedDate

Gets or sets the selected date to select the particular date of the date picker.

DayHeaderText

DayHeaderText(From DatePickerColumnHeaderView)

Gets or sets the day header text to change the day column header.

DayInterval

DayInterval

Gets or sets the day interval to restrict the visible days.

Format

Format

Gets or set the format that is used to change the format of SfDatePicker.

MaximumDate

MaximumDate

Gets or sets the maximum date to restrict the visible dates in the SfDatePicker.

MinimumDate

MinimumDate

Gets or sets the minimum date to restrict the visible dates in the SfDatePicker.

MonthHeaderText

MonthHeaderText(From DatePickerColumnHeaderView)

Gets or sets the month header text to change the month column header.

MonthInterval

MonthInterval

Gets or sets the month interval to restrict the visible months.

OkCommand

AcceptCOmmand

Gets or sets a command to accept a selected date of SfDatePicker.

YearInterval

YearInterval

Gets or sets the year interval to restrict the visible years.

YearHeaderText

YearHeaderText(From DatePickerColumnHeaderView)

Gets or sets the year header text to change the year column header.

PickerBase

Xamarin SfDatePicker .NET MAUI SfDatePicker Description

BackgroundColor

Nil Not Supported.

BorderColor

Nil Not Supported.

CancelButtonBackgroundColor

BackgroundColor(From PickerFooterView)

Gets or sets the background color of the footer.

CancelButtonTextColor

TextColor(From TextStyle of PickerFooterView)

Gets or sets the text color of the text style.

ColumnHeaderBackgroundColor

BackgroundColor(From DatePickerColumnHeaderView)

Gets or sets the background color of the column header.

ColumnHeaderFontAttributes

FontAttributes(From TextStyle of DatePickerColumnHeaderView)

Gets or sets the font attribute of the column header text style.

ColumnHeaderFontFamily

FontFamily(From TextStyle of DatePickerColumnHeaderView)

Gets or sets the font family of the column header text style.

ColumnHeaderFontSize

FontSize(From TextStyle of DatePickerColumnHeaderView)

Gets or sets the font size of the column header text style.

ColumnHeaderHeight

Height(From DatePickerColumnHeaderView)

Gets or sets the height of the column header.

ColumnHeaderTextColor

TextColor(From TextStyle of DatePickerColumnHeaderView)

Gets or sets the text color of the column header text style.

EnableLooping

Nil Not Supported.

FooterHeight

Height(From PickerFooterView)

Gets or sets the height of the footer view.

FooterView

FooterView

Gets or sets the value of footer view. This property can be used to customize the Footer in DatePicker.

HeaderBackgroundColor

BackgroundColor(From PickerHeaderView)

Gets or sets the background color of the header.

HeaderFontAttribute

FontAttribute(From TextStyle of PickerHeaderView)

Gets or sets the font attribute of the header text style.

HeaderFontFamily

FontFamily(From TextStyle of PickerHeaderView)

Gets or sets the font family of the header text style.

HeaderFontSize

FontSize(From TextStyle of PickerHeaderView)

Gets or sets the font size of the header text style.

HeaderHeight

Height(From PickerHeaderView)

Gets or sets the height of the header.

HeaderTextColor

TextColor(From TextStyle of PickerHeaderView)

Gets or sets the text color of the header text style.

HeaderView

HeaderView

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

IsOpen

IsOpen

Gets or sets the open to allow the dialog mode.

ItemHeight

ItemHeight

Gets or sets the item height of each item source.

OkButtonBackgroundColor

BackgroundColor(From PickerFooterView)

Gets or sets the background color of the footer.

OkButtonTextColor

TextColor(From TextStyle of PickerFooterView)

Gets or sets the text color of the text style.

PickerHeight

Nil Not Supported.

PickerWidth

Nil Not Supported.

SelectionBackgroundColor

BackgroundColor(From PickerSelectionView)

Gets or sets the background color of the selected item.

SelectedItemFontAttributes

FontAttributes(From SelectedTextStyle of PickerBase)

Gets or sets the font attribute of the selected text style.

SelectedItemFontFamily

FontFamily(From SelectedTextStyle of PickerBase)

Gets or sets the font family of the selected text style.

SelectedItemFontSize

FontSize(From SelectedTextStyle of PickerBase)

Gets or sets the font size of the selected text style.

SelectedItemTextColor

TextColor(From SelectedTextStyle of PickerBase)

Gets or sets the text color of the selected text style.

ShowColumnHeader

Nil Not Supported.

ShowFooter

Nil Not Supported.

ShowHeader

Nil Not Supported.

UnSelectedItemFontAttributes

FontAttributes(From TextStyle of PickerBase)

Gets or sets the font attributes of the unselected text style..

UnSelectedItemFontFamily

FontFamily(From TextStyle of PickerBase)

Gets or sets the font family of the unselected text style..

UnSelectedItemFontSize

FontSize(From TextStyle of PickerBase)

Gets or sets the font size of the unselected text style..

UnSelectedItemTextColor

TextColor(From TextStyle of PickerBase)

Gets or sets the text color of the unselected text style..

Enums

Xamarin SfDatePicker .NET MAUI SfDatePicker Description

DateFormat

PickerDateFormat

Defines the date format for the date picker.

PickerMode

PickerMode

Defines the mode of the date picker.

Events

Xamarin SfDatePicker .NET MAUI SfDatePicker Description

Opened

Opened

Occurs whenever opened on the date picker.

Closed

Closed

Occurs whenever closed on the date picker.

Closing

Closing

Occurs whenever closing on the date picker.

DateSelection

SelectionChanged

Occurs whenever selection changed on the the date picker.

OkButtonClicked

OkButtonClicked

Occurs whenever footer ok button is clicked in the date picker.

CancelButtonClicked

CancelButtonClicked

Occurs whenever footer cancel button is clicked in the date picker.

Upcoming Features

  • Enable looping support.