tags:

views:

29

answers:

1

I have a simple WPF window. I intend to set it's background to be one of the images I added to project as Embedded Resource. This is what I tried:

<Window x:Class="A_Boggle.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="A-Boggle" Height="300" Width="625" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Name="Game">
<Window.Background>
    <ImageBrush ImageSource="background.jpg"></ImageBrush>
</Window.Background>
<Grid>
</Grid>

But with this, i always get this: "Error 1 The file splash.jpg is not part of the project or its 'Build Action' property is not set to 'Resource'."

Any ideas?

+4  A: 

Go to the image within VS and set the item to be a Resource. Right click -> Properties -> Build Action -> Resource

Update:

You need to change the path if it is in a folder. ie...Resources/background.jpg

Aaron
Right. Note that 'Resource' is different than 'Embedded Resource'.
codekaizen
Still not working, getting the same error. Does it matter that image is in Resources folder?
sokolovic
@sokolovic See above
Aaron
It works now! Thanks!
sokolovic
@sokolovic, don't forget to accept the answer if it works
Thomas Levesque