XAML event for background image rendered off screen

Go To StackoverFlow.com

1

I am setting a background image on my XAML Grid with a Uri. The Uri points off to a HTTP url, where it will fetch, and then render the image as a background for a Win8 metro app.

I've been trying to figure out if there is an event or something I can hook into to let me know that WPF has loaded it into memory, AND finished rendering it out of view.

Currently, a small image will load fast enough, and smoothly fade in. However, if I load a larger, slower image, it will take 100s of ms to show up as the background, which means it either pops up mid-fade, or after the fade effect has completed. This looks quite poor.

The goal is to have a fade transition between app pages (I already have this), without the inconsistency of the background image popping up whenever it's done.

Any suggestions would be welcomed.

2012-04-04 21:37
by Ty Norton
Is it WPF or XAML/WinRT (aka Metro)? Not the same - jv42 2012-04-06 08:21
Sorry, it's XAML/WinRT - Ty Norton 2012-04-15 03:32


3

You don't say exactly how you're loading the image but there's a DownloadCompleted event on BitmapImage, e.g.

BitmapImage bmp = new BitmapImage(imageUri); 
bmp.DownloadCompleted += ReadyToDisplay; 
2012-04-04 21:42
by Phil


0

Like Phil said, but then for Windows Store apps:

BitmapImage bmp = new BitmapImage(imageUri);
bmp.ImageOpened += ReadyToDisplay;

ImageOpened Occurs when the image source is downloaded and decoded with no failure. You can use this event to determine the size of an image before rendering it.

source: MSDN

2013-04-11 19:06
by ReinierDG
Ads