使用System.Windows.Media.Imaging.BitmapImage类的DownloadProgress事件,再配合ProgressBar等控件即可做出进度条效果,下面代码中就只简单的使用TextBlock显示进度

1、MainPage.xaml代码

>
/>
/>
>

2、MainPage.xaml.cs代码

class MainPage : UserControl
   2: {
   3:     BitmapImage bitmapImage;
   4:  
public MainPage()
   6:     {
   7:         InitializeComponent();
new RoutedEventHandler(MainPage_Loaded);
   9:     }
  10:  
object sender, RoutedEventArgs e)
  12:     {
new BitmapImage();
  14:         img.Source = bitmapImage;
);
  16:         img.Stretch = Stretch.Fill;
new EventHandler<DownloadProgressEventArgs>(bitmapImage_DownloadProgress);
  18:     }
  19:  
object sender, DownloadProgressEventArgs e)
  21:     {
, e.Progress);
  23:     }
  24: }

相关文章: