Search code examples
c#timepickermaui

Open .Net Maui TimePickerdialog programatically


I am writing a ContentView with an Entry in it. When on IOS or Android I want to open the respective "TimePickerdialog" of the Platform when the user taps the Entry. On Desktop or when configured in the IOS/Android App, the user should be able to use the Entry to type in the Time by Keyboard. Is there a way to open it programmatically? I looked at some GitHub repositories where people wrote their TimePickers but it seems, that nobody triggers it programmatically but uses the TimePicker control as the base and not an Entry.


Solution

  • When on IOS or Android I want to open the respective "TimePickerdialog" of the Platform when the user taps the Entry

    At first, this design has conflict when the user taps the entry. Usually, the soft keyboard will show when the user taps the entry and trigger the entry's focused event. But you want to open the respective "TimePickerdialog" when user taps it and also want user can input the time by the keyboard.

    A touch has two different behaviors, if so, you need to use the custom control and custom render for the each platform to deal with the conflict.

    In addition, I think user selecting time is equivalent to user typing time with the keyboard. So you don't have to do a such design.