Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to evaluate the DisplayAlert return

$
0
0

Hi! I'm trying to evaluate the bool value returned from a DisplayAlert to decide whether to stop or not an ActivityIndicator, but can't evaluate the returned value in an if statement. I'm launching the DisplayAlert after a 10sec timer in my code, not with a button like in the code sample of the guide so I don't know if the code should be that way.

Here's what I've tried so far, and the condition doesn't apply(just pasted the relevant code):

var loadingCue = new ActivityIndicator{
                Color = Color.Black,
                IsRunning = true
            };    
var bienvenida = new Label {
                    Text = "Welcome; loading...",
                    TextColor = Color.Red,
                    Font = Font.SystemFontOfSize(12),
                    HorizontalOptions = LayoutOptions.Center

                };


    Device.StartTimer (new TimeSpan (0, 0, 10), () => {

                    var tiempo = DisplayAlert ("time passed", "time has passed buddy", "ok", "no way!");

    //not working       if(tiempo.Equals(true) )

    //not working       if(value == true) 

     //not working  if(value.Equals(Boolean.TrueString()) )

                    {
                        bienvenida.Text = "im glad; time's up";
                        loadingCue.IsRunning = false;
                        return false;
                    }
                    else {
                        bienvenida.Text = "time keeps running buddy...";
                        return true;
                    }


                });

Do I need to use the await/async in this case too? It may be a simple C# thing(I don't know C# either; but I know java and I see it works to get a head start with Xamarin), but I can't decipher it so far.

Any help would be appreciated; thanks


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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