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:
DatePicker
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?
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 ...
}