Press OK to get the datetime

Hi SyncFusion,
I know the way to get the selected value of the DateTime is to call DateSelected() to get NewValue.
I want to revise the action to get the datetime value.
The default way is when I changing the date then it will activate the DateSelected function. What I want is to get the datetime by pressing the OK button in the footer and then close the sfDatePicker automatically.
Is there any way to achieve it?

Thanks for kindly response.

reference: https://help.syncfusion.com/xamarin/datepicker/customizations?cs-save-lang=1&cs-lang=csharp

1 Reply 1 reply marked as answer

RS Ruba Shanmugam Syncfusion Team January 29, 2021 08:38 AM UTC

Hi HannahC,

Greetings from Syncfusion.

We have validated your query and we would like to let you know that you can get the DateChangedEventArgs in OkButtonClicked event. Please refer the below sample and code snippet.

Code Snippet: 
XAML: 
<picker:SfDatePicker x:Name="datePicker"
                                      PickerWidth="300"
                                      PickerHeight="300"
                                      PickerMode="Dialog"
                                      ShowFooter="True"
                                      OkButtonClicked="SfDatePicker_OkButtonClicked"/>

XAML.cs:

private void SfDatePicker_OkButtonClicked(object sender, Syncfusion.XForms.Pickers.DateChangedEventArgs e)
{
          DisplayAlert("Notification", "SelectedItem" + e.NewValue.ToString(), "Ok");
 
  
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/DatePickerEvents-1594379228

Please let us know, if you have any other concerns.

Regards,
Ruba Shanmugam 


Marked as answer
Loader.
Up arrow icon