I decided to have a go and got it working. The only catch is, it s a bit of a workaround since there seems to be some strange behaviour with the ImageOpened
event. Basically, the ImageOpened
event of the Brush
doesn t get called when you assign the background to the frame. Strangely, it does get called when you assign it to an element. So I just created a hidden button and assigned the brush to that (to force the ImageOpened
event to fire). I then assigned it to the frame and it works for me. Seems like a bug, but the workaround below works for me.
ImageBrush brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri("/myImage.jpg", UriKind.Relative));
//hide the fake button and set the brush to be its background
button1.Visibility = System.Windows.Visibility.Collapsed;
button1.Background = brush;
//assign it to the frame (or using RootFrame in your case)
var frame = App.Current.RootVisual as PhoneApplicationFrame;
frame.Background = brush;