Hide WP7 progress bar when the image is loaded
I'm using a progress bar for loading an image in an application for Windows Phone 7.
bitmapImage.DownloadProgress += new EventHandler<DownloadProgressEventArgs (bitmapImage_DownloadProgress); void bitmapImage_DownloadProgress(object sender, DownloadProgressEventArgs e) { progressBar.Value = e.Progress; }
XAML file:
<ProgressBar x:Name="progressBar" IsIndeterminate="True" Width="300" Height="30" Style="{StaticResource PerformanceProgressBar}" />
I'd like to know the best way to make the progress bar disappear once the image is loaded.
Answers & Comments...
Answer: 1
Answer: 2
Answer: 1
Simply hide it via the Visibility
property
progressBar.Visibility = Visibility.Collapsed
by : ColinEhttp://stackoverflow.com/users/249933Answer: 2
Use the events ImageOpened
which triggers when image has been loaded successfully and ImageFailed
which triggers if image failed to download.
bitmapImage.ImageOpened += new EventHandler<RoutedEventArgs>(bi_ImageOpened); bitmapImage.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(bi_ImageFailed); void bi_ImageFailed(object sender, ExceptionRoutedEventArgs e) { MessageBox.Show("Download of image failed"); progressBar.Visibility = Visibility.Collapsed; } void bi_ImageOpened(object sender, RoutedEventArgs e) { progressBar.Visibility = Visibility.Collapsed; }
by : Johan Falkhttp://stackoverflow.com/users/1330240
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog