BitmapImage.DownloadProgress 事件

定义

BitmapImage 内容的下载进度发生重大更改时发生。

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

事件类型

示例

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

注解

对于 BitmapImage 对象的异步加载和解码时间足以引起用户注意的情况,应用可以在源上处理 DownloadProgress,并显示 ProgressRingProgressBar 以指示进度状态。 它们可能显示在图像最终显示的 UI 区域中,或显示在 UI 中的其他位置。 使用 DownloadProgressEventArgs.Progress 修改 ProgressBar 的 UI。

适用于

另请参阅