BitmapImage.DownloadProgress Event

Definition

Occurs when a significant change has occurred in the download progress of the BitmapImage content.

C#
public event DownloadProgressEventHandler DownloadProgress;
XAML
<BitmapImage DownloadProgress="eventhandler"/>

Event Type

Examples

C#
// somewhere in initialization
bitmapImage.DownloadProgress += new EventHandler<DownloadProgressEventArgs>(bi_DownloadProgress);
bitmapImage.ImageOpened += new EventHandler<ExceptionRoutedEventArgs>(bi_ImageOpened);
...
//progressBar is an existing control defined in XAML or extracted from a XAML template

void bi_DownloadProgress(object sender, DownloadProgressEventArgs e)
{
     progressBar.Value = e.Progress;
}
void bi_ImageOpened(object sender, RoutedEventArgs e)
{
     progressBar.Visibility = Visibility.Collapsed;
}

Remarks

For cases where the async loading and decoding of a BitmapImage object are long enough to be noticeable to the user, an app can handle DownloadProgress on the source and display a ProgressRing or ProgressBar to indicate the progress state. These might display in the UI region that the image eventually displays in, or somewhere else in the UI. Use DownloadProgressEventArgs.Progress to modify the UI for a ProgressBar.

Applies to

Proizvod Verzije
Windows App SDK 0.8, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6

See also