Tant que votre ImageSource est un BitmapImage, vous pouvez utiliser l'événement BitmapImage.DownloadCompleted. Le seul problème que j'ai trouvé jusqu'ici est qu'il ne fonctionne que de C#, donc vous perdriez de la flexibilité. Je suppose que vous pouvez accéder à cet événement à partir de XAML, mais je ne sais pas comment. L'exemple suivant commence à charger l'image avec le clic d'un bouton et met à jour une étiquette lorsque l'image a terminé le chargement.
XAML:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Image x:Name="image" Grid.Row="2"/>
<Label x:Name="label" Content="aaa" Grid.Row="1" />
<Button Click="Button_Click" Content="Click to load image" Grid.Row="0" />
</Grid>
code:
private void Button_Click(object sender, RoutedEventArgs e)
{
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.DecodePixelHeight = 100;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.UriSource = new Uri("bigImageUri");
bi.EndInit();
bi.DownloadCompleted += new EventHandler(bi_DownloadCompleted);
image.Source = bi;
}
void bi_DownloadCompleted(object sender, EventArgs e)
{
label.Content = "dl completed";
}
Hope it helps!
VB: 'AddHandler bi.DownloadCompleted, bi_DownloadCompleted' – sinni800