共用方式為


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

備註

對於 點陣圖Image 物件的非同步載入和解碼夠長的使用者而言,應用程式可以處理來源上的 DownloadProgress,並顯示 ProgressRingProgressBar 來指出進度狀態的情況。 這些可能會顯示在影像最終顯示于 UI 區域中,或在 UI 中其他位置顯示。 使用 DownloadProgressEventArgs.Progress 來修改 ProgressBar的 UI。

適用於

另請參閱