This project is read-only.

[Version 1.3] Images not showing in floating window

Oct 16, 2011 at 7:15 PM

I have a problem as follows which I'd be hugely grateful if anyone can shed any light, or tell me what the solution is.

I have a Canvas inside a ScrollViewer which forms the content of a DocumentContent. As the programme runs, things get loaded onto the canvas, one of which is a Textbox, with a .png file behind as a backdrop. Everything works fine until the Document is dragged out to a floating window. After that, any new images that I try to load onto the canvas don't show. Also, my ContextMenu for the Canvas has icons which also do not show if I don't right-click until the window is floating. If I right-click before the window is floating the icons show properly.

I should point out that both the types of images described above (the ones on the Canvas and the ones on the ContextMenu) are added using C#. I have been able to get around this problem by adding the images in XAML instead for some of my canvas object, but this going to cause a big problem for me in the future. The code I use to add images is as follows:

MenuItem addSFVComp = new MenuItem();

Image img = new Image();          

ImageSource src = new BitmapImage(new Uri("Icons\\gears.png", UriKind.RelativeOrAbsolute));           

img.Source = src;

addSFVComp.Icon = img;

Like I said, everything works perfectly unless the window is floating, and then everything else that's added shows (shapes, text boxes etc.) except the .png files.

 

Can anybody help me out?