0

I have a custom DatePicker, which is opened if the user taps on it. It uses the same mechanics like the Xamarin.Forms DatePicker. The scenario is like the following:

  • user taps on the custom DatePicker
  • instead of picking a date he opens another dialog
  • two dialogs are now opened at the same time

I tried to Unfocus() if the other element get's the focus, but nothing happens. The DatePicker is still displayed.

What else can I do? Should I throw manually the Unfocus event? Can I lock the UI somehow so that the user has to press the Finish button before moving on?

testing
  • 19,681
  • 50
  • 236
  • 417

1 Answers1

1

First, the issue doesn't occur if I switch between DatePicker and TimePicker. It only occurs if I switch from DatePicker/TimePicker to my Entry (which triggers a custom dialog in Focused event).

And Unfocus() does work, if you do it on the UI thread:

private async void someEntry_Focused(object sender, FocusEventArgs e)
{
    Device.BeginInvokeOnMainThread(() =>
    {
        this.datePicker.Unfocus();
    });
    // custom dialog shown to user ...
}
testing
  • 19,681
  • 50
  • 236
  • 417