How can I set a default or starting value for a Xamarin.Forms DatePicker?
At the moment, it begins on January 1st, 1900. This isn't a very useful date, and worse, a user has to scroll needlessly to get the right year, then the right month.
I'd like the default date to be the current date. I know how to get the current date, and I can set MinimumDate attribute of the DatePicker tag in the .xaml. This will make the current date the start date of the picker, but then I can't go back to a previous year or month.
Thanks,
You can just set Date property directly on xaml:
<DatePicker x:Name="datePicker" Date="{x:Static system:DateTime.Today}" />
you need to use
xmlns:system="clr-namespace:System;assembly=mscorlib"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With