Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

"Today" button for DatePicker?

KarenCateKarenCate USMember ✭✭

Hello all!

In our desktop product, our calendar control has a "today" button. It would be handy to have that feature available on the mobile product. Does anyone have any hints as to how that might be accomplished?

I know the obvious answer is to put a button next to the date picker anchor in the main UI, but (stop me if you've heard this one...) I don't really have space. I was kind of hoping to find a way to get it to show up in the picker dialog that pops up. Any suggestions?

Thanks!
-Karen

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Do you want to add a button in the DatePicker UI ?

    Why not try DatePickerRenderer?

  • KarenCateKarenCate USMember ✭✭

    @jezh

    I don't have a background in Android development. I've managed to tweak a couple of renderers, but I just don't have the know-how to tackle this one. From what I can tell, it doesn't look like I can just add a button to the DatePickerDialog, so I'd have to build my own from scratch. I was hoping someone would have or know of an extendable/modifiable date control so I didn't have to make one. I don't think I have the time available to learn what I'd need to build my own.

  • PatrickJelittoPatrickJelitto Member ✭✭✭

    why dont you bind your datepickers date attribute to a property which returns DateTime.Now(), so today is the standard case?

  • KarenCateKarenCate USMember ✭✭

    @PatrickJelitto Because I need to know if the user has changed it or not. I actually started out doing that, but then if the user doesn't change the value, the empty date value in our database suddenly gets set to today. I've been using DateTime.MinValue to indicate that the date is null in the database (because c# DateTimes cannot be null, but MySQL dates can be), and that's a LOT of scrolling to get to today.

    The Date control in our desktop software has Today and Clear buttons below a small month calendar. That's a much better paradigm for our application, and our customers are used to it. But I'm certainly not in a position to write one.

  • ron123ron123 Member

    @KarenCate I am trying to do something similar that you had asked for. Were you able to find the best way to add "today" option in Date Picker UI?

Sign In or Register to comment.