Beispiel #1
0
        public async Task LoadImage()
        {
            DoubleAnimation da = new DoubleAnimation
            {
                From        = 0,
                To          = 1,
                Duration    = new Duration(TimeSpan.FromSeconds(2)),
                AutoReverse = true
            };

            Spinner.BeginAnimation(OpacityProperty, da);

            image.Visibility   = Visibility.Hidden;
            Spinner.Visibility = Visibility.Visible;
            path = "https://dog.ceo/api/breeds/image/random";
            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.GetAsync(path);

            if (response.IsSuccessStatusCode)
            {
                dynamic picsResponse = await response.Content.ReadAsStringAsync();

                Console.WriteLine(picsResponse);

                Pic pic = JsonConvert.DeserializeObject <Pic>(picsResponse);
                UpdateImage(pic.message);
            }
            Spinner.Visibility = Visibility.Hidden;
            image.Visibility   = Visibility.Visible;
        }