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
close icon

not able to bind date variable with datepicker

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"/>
                    </sfTextLayout:SfTextInputLayout>
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?


3 Replies

RA Rachel A Syncfusion Team 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. 
 
 
Regards, 
Rachel. 



KR Krunal 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?


RA Rachel A Syncfusion Team 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. 
 
Thanks, 
Rachel.  


Loader.
Live Chat Icon For mobile
Up arrow icon