We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

not able to bind date variable with datepicker

Thread ID:





150265 Dec 30,2019 06:54 AM UTC Jan 7,2020 06:38 AM UTC Xamarin.Forms 3
Tags: SfTextInputLayout
Asked On December 30, 2019 06:54 AM UTC

I have used the sfDatePicker and have following code in my xaml :

<sfTextLayout:SfTextInputLayout ContainerType="None" Hint="Birth Date" Grid.Column="0">
                        <DatePicker Date="{Binding Birthdate}" Format="dd-MMM-yyyy"/>
Birthdate property is defined in my view model and it has RaisePropertyChanged implemented in property. When page with this control opens, datepicker always opens with default date i.e. current date irrespective of the date set in "BirthDate" variable. I want this control to take the date which I set from code behind instead of default value.

Another issue is data type of variable Birthdate is nullable datetime hence when its value is null, picker control should not show any date value and remain blank however upon encountering null value picker control shows default value i.e. current date.

Can you provide fix for above two issues?

Rachel A [Syncfusion]
Replied On January 2, 2020 09:14 AM UTC

Hi Krunal, 
Greetings from Syncfusion. 
Query 1: Binding date to date picker 
Yes, we can bind date from view model to date picker with two way binding as demonstrated in the below sample. The sample can be downloaded from the below link. 
Query 2: Displaying empty string if date is null 
In Xamarin Forms date picker there is no currently direct support to display it as empty when the date value is null. 
Find some of the reference link below. 

Replied On January 6, 2020 09:30 AM UTC

I finally managed to figure out the reason for issue 1 and now it is working. Thanks for your support.

Issue 2 is very common requirement. Can you add this as feature in date picker and add this as feedback?

Rachel A [Syncfusion]
Replied On January 7, 2020 06:38 AM UTC

Hi Krunal, 
You can log the feature request for the Xamarin Forms Date picker in the below link. 
Since you are using Xamarin Forms date picker control, it is not possible to log this as Syncfusion feedback. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon