Image 如何知道映像在windows phone中绑定在xaml中?

Image 如何知道映像在windows phone中绑定在xaml中?,image,windows-phone-7,windows-phone-8,imageview,windows-phone-8.1,Image,Windows Phone 7,Windows Phone 8,Imageview,Windows Phone 8.1,我有一个图像url,并将其绑定到xaml。但我不知道它是什么时候在xaml中出现的。所以我不能把它放在吧台上。 我的代码: XAML: <Image Grid.Row="1" x:Name="viewimg"/> .CS : viewimg.Source = (ImageSource)new ImageSourceConverter().ConvertFromString((string) (App.Current as App).linkimage480);

我有一个图像url,并将其绑定到xaml。但我不知道它是什么时候在xaml中出现的。所以我不能把它放在吧台上。 我的代码:

XAML:  <Image Grid.Row="1" x:Name="viewimg"/>
.CS : viewimg.Source = (ImageSource)new ImageSourceConverter().ConvertFromString((string)          (App.Current as App).linkimage480);
XAML:
.CS:viewimg.Source=(ImageSource)new ImageSourceConverter().ConvertFromString((string)(App.Current作为App.linkimage480);

使用
ImageOpened
事件,如果出现问题,还会出现
ImageFailed

编辑: 将
ImageOpened
事件添加到XAML:

然后在代码中我会做:

BitmapImage bm = new BitmapImage();
bm.ImageFailed += delegate { // Code to execute when binding fails };
bm.UriSource = new Uri("http://imagesource.com", UriKind.Absolute);
viewimg.Source = bm;

因为我认为当您将
ImageFailed
添加到XAML
Image
控件中,并且故障发生在您的ImageSource中时,事件将不会被触发

你能多谈谈吗?如果你能为我编写演示代码吗?非常感谢。我尝试了你的方法,但我发现当图像显示在XAML上时,ImageOpen函数就会出现。当图像未在XAML上显示时,我希望出现一个ProgesBar,在图像显示后,我希望关闭ProgesBar。private void viewimg_ImageOpened(对象发送方,RoutedEventTargets e){progess.IsIndeterminate=true;BitmapImage bm=new BitmapImage();bm.ImageFailed+=委托{};bm.UriSource=new Uri((App.Current asApp.linkimage480,UriKind.Absolute);viewimg.Source=bm;progess.IsIndeterminate=false;}您能帮助我吗?谢谢您在这种情况下,您只需在开始加载图像(即设置bm.UriSource)时显示进度条,然后在ImageOpened事件中隐藏它。好的,就这么简单,但我不这么认为。比你好多了。