本文介绍了如何确定从URI成功加载的Bitmapimage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想验证位图图像是否已成功加载图像。 我尝试过以下但没有用。如果有人知道答案,请帮助我。 string strImageName =/ TestApp; component / Images /+ shortDesc +巴纽; // if(!System.IO.File.Exists(strImageName)) // strImageName =/ TestApp; component / images / DEFAULT.png; var uriSource = new Uri(strImageName,UriKind.Relative); BitmapImage image = new BitmapImage(uriSource); image.DecodeFailed + = new EventHandler < ExceptionEventArgs > (image_DecodeFailed); image.DownloadFailed + = new EventHandler < ExceptionEventArgs > (image_DownloadFailed); void image_DecodeFailed( object sender,ExceptionEventArgs e) { } void image_DownloadFailed( object sender,ExceptionEventArgs e) { MessageBox。显示( 失败); } 解决方案 I want to validate the bitmap image has loaded image successfully.I have tried with the below but did not work. Please help me if any body know the answer.string strImageName = "/TestApp;component/Images/" + shortDesc + ".png"; //if (!System.IO.File.Exists(strImageName)) // strImageName = "/TestApp;component/Images/DEFAULT.png"; var uriSource = new Uri(strImageName, UriKind.Relative); BitmapImage image = new BitmapImage(uriSource); image.DecodeFailed += new EventHandler<ExceptionEventArgs>(image_DecodeFailed); image.DownloadFailed += new EventHandler<ExceptionEventArgs>(image_DownloadFailed);void image_DecodeFailed(object sender, ExceptionEventArgs e) { } void image_DownloadFailed(object sender, ExceptionEventArgs e) { MessageBox.Show("Failed"); } 解决方案 这篇关于如何确定从URI成功加载的Bitmapimage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-29 14:48