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; }); }
private void wc_picOpenReadImg(string url) { if (DeviceNetworkInformation.IsNetworkAvailable) { progressBar1.IsIndeterminate = true; //显示加载中的图片 srcimage.UriSource = new Uri("/Images/xxxxxx.png", UriKind.Relative); //网络上的图片 srcimage.UriSource = new Uri(url, UriKind.Absolute); } else { MessageBox.Show("网络未打开,请检查wifi或数据是否已开启。"); } }