Display Alert not showing on UI in Xamarin Forms Application

Matt Alanskas 1 Reputation point
2022-12-19T20:31:43.89+00:00

I have a Xamarin Forms application issue going on. I use display alert throughout the application in the same way, and it works every time. When I call this specific function, the display alert gets hit as a breakpoint when I debug, but the actual alert never displays on my application. I have attached the code that is causing me problems. The Display Alert is being hit, so I am at a lost why its not showing on the UI. Thanks! This is a ContentPage in a View

  public async void dfuState(string dfuState)   
    {   
        bool answer = false;   
        if (dfuState == "Completed")   
        {   
            MainThread.BeginInvokeOnMainThread(async () =>   
            {   
                await DisplayAlert("Alert", "No internet connection", "Ok");   
                // Code to run on the main thread   
            });   
            if (answer)   
            {   
                await Task.Delay(1000);   
                SelectADevicePageViewModel._instance.SelectedDevice = null;   
                DfuInstallationConfigurationPageViewModel._instance = new DfuInstallationConfigurationPageViewModel();   
                await Application.Current.MainPage.Navigation.PopAsync();   
            }   
        }   
    }
Developer technologies .NET Xamarin
{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.