开发者

How to check BitmapImage instance is initialized or not? WPF

I try to开发者_JS百科 use instances of BitmapImage class in circle but sometimes I receive error messages that BitmapImage is not initialized. How to check that BitmapImage is initialized before use it?


There 2 Events commonly used when working Bitmaps, 1 fires of when Image successfully opened and another when Image failed;

var myImage = new BitmapImage(new Uri(@"Images/img.jpeg",UriKind.Relative));
            myImage.ImageOpened += myImage_ImageOpened;
            myImage.ImageFailed += myImage_ImageFailed;


        void myImage_ImageFailed(object sender, ExceptionRoutedEventArgs e)
        {
            //handle failed event
        }

        void myImage_ImageOpened(object sender, RoutedEventArgs e)
        {
           //handle Image Opend OK event
        }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜