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

ActivityIndicator Not Working

$
0
0

I'm new to the forums, so sorry if this is a repeat. I posted here, https://forums.xamarin.com/discussion/comment/69532?
but I suspect that thread is marked as answered.

I've got an ActivityIndicator that's not showing up at all, and I'm sure if it's because of my layout, or if I'm blocking the UI thread, or what. I've researched a lot without any luck. Here's the code. Some of the code is likely unnecessary. It's just there because I was trying different things.

            var loadingModal = new ActivityIndicator()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Color = Color.Silver,
                IsRunning = true,
                IsEnabled = true,
                IsVisible = false
            };
            loadingModal.BindingContext = this;
            loadingModal.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy", BindingMode.OneWay);
            this.IsBusy = false;
            var button = new Button { Text = "Login" };
            button.Clicked += (sender, e) =>
            {
                    this.IsBusy = true;
                    Task.Delay(2);
                    using (var httpClient = new HttpClient())
                    {
                        try
                        {
                            var request = httpClient.GetStringAsync("http://10.6.1.23/RestMobile/Home/Login?username=" + name + "&password=" + pass).Result;
                            //more http requests
                            this.IsBusy = false;
                            App.Current.Properties["IsLoggedIn"] = true;
                            App.Current.ShowMainPage();
                        }
                        catch (Exception ex) {
                            ex.ToString();
                        }
                    }

                }
            };

            username = new Entry { Text = "" };
            password = new Entry { Text = "", IsPassword = true };
            var layout = new StackLayout
            {
                Padding = new Thickness(10, 40, 10, 10),
                Children = {
                        loadingModal,
                        new Label {Text = "Login", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))},
                        new Label {Text = "Username"},
                        username,
                        new Label {Text = "Password"},
                        password,
                        button
                    }
            };

            Content = layout;

Viewing all articles
Browse latest Browse all 75885

Trending Articles



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