1

リモートデータベースから画像を表示する必要があります。ここには、ローカルファイルから画像を表示するコードがありますが、リモートサーバーから取得できません

C#コード

DispatcherTimer timer = new DispatcherTimer();
        List<string> files = new List<string>() { "http://technomindtech.com/1tele-pixel.com/ad/banner.jpg", "http://technomindtech.com/1tele-pixel.com/ad/logo_banner.jpg", "http://technomindtech.com/1tele-pixel.com/ad/images.jpeg" };


        List<BitmapImage> images = new List<BitmapImage>();
            int current = 0;

                foreach (string file in files)
                {
                    BitmapImage image = new BitmapImage(new Uri(file, UriKind.Relative));
                    images.Add(image);
                }

                timer = new DispatcherTimer();
                timer.Interval = TimeSpan.FromSeconds(3);
                timer.Tick += new EventHandler(timer_Tick);

                timer.Start();

     void timer_Tick(object sender, EventArgs e)
            {
                Image1.Source = images[current];

                current++;
                if (current >= files.Count)
                    current = 0;
            }

Xamlコード

<Image x:Name="Image1"  Stretch="Fill" Width="410" Grid.ColumnSpan="3" Margin="-8,0,-29,0"  />

しかし、Uri例外がスローされ、画像を表示できません

4

1 に答える 1