Time Picker Focus and UnFocus is not working

Chinmay Dole 200 Reputation points
2024-12-27T08:55:24.1366667+00:00

Hello,

There is a known issue for DatePicker focus unfocus not working on .NET MAUI 8 Android. The below code helped me to solve the date picker issue:-


  private DatePickerDialog mDialog;

    protected override DatePickerDialog CreateDatePickerDialog(int year, int month, int day)
    {
        mDialog = base.CreateDatePickerDialog(year, month, day);
        return mDialog;
    }

    protected override void ConnectHandler(MauiDatePicker platformView)
    {
        base.ConnectHandler(platformView);
        mDialog.ShowEvent += OnDialogShown;
        mDialog.DismissEvent += OnDialogDismissed;
    }

    private void OnDialogShown(object sender, EventArgs e)
    {
        VirtualView.IsFocused = true;
    }

    private void OnDialogDismissed(object sender, EventArgs e)
    {
        VirtualView.IsFocused = false;
    }

Git hub link:- https://github.com/dotnet/maui/issues/18797

I need a similar solution for the time picker to solve my Focus and Unfocus issue. Also on iOS Date Picker the unfocus is triggered even before tapping the done button which leads to infinite loop

Please Help

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,768 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.