Share via

Time Picker Focus and UnFocus is not working

Chinmay Dole 300 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

Developer technologies | .NET | .NET MAUI

Your answer

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