BitmapImage.DownloadProgress 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
發生于 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 物件的非同步載入和解碼夠長的使用者而言,app 可以處理來源上的 DownloadProgress,並顯示 ProgressRing 或 ProgressBar 來指出進度狀態的情況。 這些可能會顯示在影像最終顯示于 UI 區域中,或 UI 中其他位置。 使用 DownloadProgressEventArgs.Progress 來修改 ProgressBar的 UI。