开发者

Cannot open many Images in WPF

开发者 https://www.devze.com 2023-02-22 03:51 出处:网络
This is my code: foreach (Database.Photo photo in eventPhotos) { Image img = new Image(); img.Height = 100;

This is my code:

foreach (Database.Photo photo in eventPhotos)
        {
            Image img = new Image();
            img.Height = 100;
            img.Width = 80;
            img.Focusable = true;
            img.MouseDown += new MouseButtonEventHandler(img_MouseDown);
            string littleString = photo.PhotoUrl;
            littleString = littleString.Replace(".jpg", "t.jpg");
            BitmapImage bi = new BitmapImage();
            bi.Begin开发者_如何学CInit();
            bi.UriSource = new Uri(littleString, UriKind.Absolute);
            bi.EndInit();
            img.Source = bi;
            imagesEvent1.Children.Add(img);
        }

But not all images are loaded.:

Cannot open many Images in WPF

in this time, images №3,5 are not loaded, in next time other images are not loaded.


The image download may be failing. Try handling the ImageFailed event on the Image control and see if that fires.

0

精彩评论

暂无评论...
验证码 换一张
取 消