I have the following code in silverlight for windows phone :
<Border CornerRadius="0" x:Name="brdTest" BorderBrush="Black" BorderThickness="4" Width="100" Height="60">
<Border.Background>
<ImageBrush x:Name="backgroundImageBrush" Stretch="Fill">
<ImageBrush.ImageSource>
<BitmapImage x:Name="bmpBackground" UriSource="http://www.images.com/1.jpg">
</BitmapImage>
</ImageBrush.ImageSource>
</ImageBrush>
</Border.Background>
</Border>
How can i add a loading activity indicator from silverlight toolkit in the image place while the image(http://www.images.com/1.jpg) loads and remove it when the image has loaded?
Do the images load in a background thread? Or do they block the main UI Thread? (i.e. i would like to use this in a template for lots of list box items)
UPDATE I tried this code and loaded a big image (70MP), and while the image was loading, the app’s main UI thread didn’t froze
You could use a
ProgressOverlay, or aPerformanceProgressBar. Here’s an example with aProgressOverlay:And in the
bmpBackground_ImageOpenedevent handler you addoverlay.Hide();which hides theOverlayProgress.This approach seems better than just using a
PerformanceProgressBaralone, because it gives the user an indication on what’s going on.PS: The
OverlayProgressdidn’t work properly for me until I added aPerformanceProgressBarin it’s “Content” as shown in the code. (try removing it and see if it works for you).I hope this helps 🙂