使用System.Media.Imaging.BitmapImage类的DownloadProgress事件,再配合Progressbar等控件即可做出进度条效果,下面代码中就只简单的使用TextBlock显示进度
1、MainPage.xaml代码
1: <GrID x:name="LayoutRoot" Background="White">
2: Image ="img"/>
3: TextBlock Text="正在加载 0%" ="TxtLoading" HorizontalAlignment="Center" Foreground="Black" VerticalAlignment="Center" 4: </GrID>
2、MainPage.xaml.cs代码
public partial class MainPage : UserControl2: {
3: BitmAPImage bitmAPImage;
4:
5: public MainPage()
6: {
7: InitializeComponent();
8: this.Loaded += new RoutedEventHandler(MainPage_Loaded);
@H_301_116@9: }
10:
11: private voID MainPage_Loaded(object sender,RoutedEventArgs e)
12: {
13: bitmAPImage = new BitmAPImage();
14: img.source = bitmAPImage;
15: bitmAPImage.UriSource = new Uri("http://192.168.178.222/test.jpg");
16: img.Stretch = Stretch.Fill;
17: bitmAPImage.DownloadProgress += new EventHandler<DownloadProgressEventArgs>(bitmAPImage_DownloadProgress);
18: }
19:
20: voID bitmAPImage_DownloadProgress(21: {
22: TxtLoading.Text = string.Format("正在加载 {0}%",e.Progress);
23: }
24: }
总结 以上是内存溢出为你收集整理的Silverlight中大图片的加载进度全部内容,希望文章能够帮你解决Silverlight中大图片的加载进度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)