Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

DisplayAlert not showing on Xamarin.Forms

$
0
0

I am a real beginner in cross-platform programming, .NET and C#.

I wrote a simple program, at the end it should pop up a window about who won the game. I'm using XAML with MVVM, I have an event in the model which gives back the winner. I did all the bindings in the XAML file, the app.cs has a private async void function which I think doesn't work for some reason.
It looks kinda like this:

    private async void GameOver(object sender, modelEvent e)
            {
                if (e.result == 0)
                {
                     await MainPage.DisplayAlert("Game", "Drawn!",
                                                "OK");
                }
                if (e.result == 1)
                {
                     await MainPage.DisplayAlert("Game", "First player won!",
                                                "OK");
                }
                if (e.result == 2) 
                {
                     await MainPage.DisplayAlert("Game", "Second player won!",
                                                "OK");
                }

            }

What might be the problem here?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>