I need to allow user to enter their credit card expiration date. For this I have to show them date picker with only month and year options. I am using format="MM-yyyy", but no luck. Can anyone help me ? Thanks.
I think you have to use a customer renderers
I'm looking into the same problem. It seems that even natively you'd have to do a few things.
For iOS you'd have to create your own UIPickerView and then set sources for month and year manually
For Android, it's not so simple, so you'd have to use reflection to modify the component directly, the example below is for removing the year, but you in theory could use the same approach for removing the day.
Sorry I don't have a copy and paste solution for you! But these are really good starting points.
Just adding to my answer, another thread which suggest the approaches above:
Nobody has shared a solution for this yet, if I get around to working on this (it's fairly low in my backlog) i'll try to share code on GitHub.
Hi guys, did you find any solutions for this one? I'm being stuck with this task for days (headbang)
We did something similar (for time rather than date) by creating a custom renderer for each platform, with the renderer replacing the native control. It might be worth looking at the Xamarin.Forms source code to see what Xamarin used, but our current implementation uses:
Android - Android.Widget.EditText and AlertDialog
iOS - UITextField and UIPickerView
UWP - Windows.UI.Xaml.Controls.UserControl and Windows.UI.Xaml.Controls.Flyout
Thanks JohnHardman. I've created it successfully with iOS platform but still don't know "where to go" with Android caused I only have some development experiences with iOS only .
I solved this but only for android using a renderer:
@DuongNguyen.0603 Can you please provide the source code
I need to show only month and year in both android and ios 's Datepicker
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies