Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

TimePicker 24h format

$
0
0

Hi,
I want my TimePicker to be displayed in a 24h format.
I can find a "lot of answers" (the same one being repeated each time) to this online, but it doesn't work for me and I don't understand how it could even work :/

Here is the code sample that I found for iOS

[assembly: ExportRenderer(typeof(TimePicker), typeof(TimePicker24HRenderer))]
namespace Example.iOS.CustomRenderer {
    public class TimePicker24HRenderer : TimePickerRenderer {
        protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e) {
            base.OnElementChanged(e);
            var view = (TimePicker)Element;

            if (view != null) {
                var timePicker = (UIDatePicker)Control.InputView;

                timePicker.MinuteInterval = 15;
                timePicker.Locale = new NSLocale("fr_FR");
            }
        }
    }
}

How is the creation of an unused variable timePicker going to do anything ?
Can anyone tell me how to make this work ?

Thanks in advance,
Théo


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>