Delen via


BitmapImage.DownloadProgress Event

Definition

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

public:
 virtual event DownloadProgressEventHandler ^ DownloadProgress;
// Register
event_token DownloadProgress(DownloadProgressEventHandler const& handler) const;

// Revoke with event_token
void DownloadProgress(event_token const* cookie) const;

// Revoke with event_revoker
BitmapImage::DownloadProgress_revoker DownloadProgress(auto_revoke_t, DownloadProgressEventHandler const& handler) const;
public event DownloadProgressEventHandler DownloadProgress;
function onDownloadProgress(eventArgs) { /* Your code */ }
bitmapImage.addEventListener("downloadprogress", onDownloadProgress);
bitmapImage.removeEventListener("downloadprogress", onDownloadProgress);
- or -
bitmapImage.ondownloadprogress = onDownloadProgress;
Public Custom Event DownloadProgress As DownloadProgressEventHandler 
<BitmapImage DownloadProgress="eventhandler"/>

Event Type

Examples

// 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

See also