WindowBackground Image

Aug 22, 2013 at 3:25 AM
Another question guys.

I am attempting to set the XAML property "WindowBackground" defined on the theme reference page defined here: Theme resource reference. This is how I am doing it:
<ImageBrush x:Key="WindowBackground" ImageSource="Images/imgConfigWindow.png"/>
However it does not work. It does work with properties such as ButtonBackground, InputBackground, etc. Pretty much any property that gets set as a Brush Type.

It just seems like the WindowBackground property isn't working with my image.

I'm probably misunderstand a concept here, but shouldn't this let me set the window a background of an image?
Aug 22, 2013 at 1:03 PM
Edited Aug 22, 2013 at 1:03 PM
This should work. Are you sure the ImageSource is available at specified location? Also check the build action of the image in your project, is it content or a resource?
Aug 22, 2013 at 1:27 PM
It is set as a Resource. As I have said, it does already work for the other properties, just not this one.
Aug 22, 2013 at 2:28 PM
My bad, it's the WindowBackground resource that doesn't work for ModernWindow. Not sure if this is a bug or not, ModernWindow uses a coloranimation to switch background colors when changing the theme at runtime.

As a workaround use the WindowBackgroundContent resource like so;
<Image x:Key="WindowBackgroundContent" x:Shared="false" Source="Images/imgConfigWindow.png" Stretch="UniformToFill"/>
Make sure x:Shared="false", so the rectangle can be re-used among ModernWindow and ModernDialog instances.
Aug 22, 2013 at 4:20 PM
Thanks again, this work-around works.