private BitmapImage srcimage = new BitmapImage();
public MainPage() { InitializeComponent(); progressBar1.IsIndeterminate = false; //进度条 srcimage.CreateOptions = BitmapCreateOptions.None; //不延时加载
srcimage.ImageOpened += new EventHandler<RoutedEventArgs>((sender, e) => { progressBar1.IsIndeterminate = false; image1.Source = srcimage; }); }
123
private void wc_picOpenReadImg(string url) { if (DeviceNetworkInformation.IsNetworkAvailable) { //中断下载过程 srcimage.UriSource = new Uri("nopic.png", UriKind.Relative); image1.Source = new BitmapImage(new Uri("/Images/appbar.sync.rest.png", UriKind.Relative)); progressBar1.IsIndeterminate = true; srcimage.UriSource = new Uri(url, UriKind.Absolute); } else { MessageBox.Show("网络未打开,请检查wifi或数据是否已开启。"); } }