Reputation: 15118
I want to change the background of the main window in my WPF application.
I have read around a lot of questions, and they all talk about adding with image tag, or assigning from resources, etc etc.
But no one actually shows how to actually get that image into the application so that it can used.
I imagine it has to be packed into the application somehow because if you send the exe to someone and you have an image tag which points to a folder on your computer locally, then they wont have that same folder or image file on theres necessarily, so how do you actually add the image in to the project, seems crazy or i might be looking in the wrong places that there is no easy or clear cut way to do this. and then use that to change the background of the window.
Upvotes: 1
Views: 120
Reputation: 853
Drag and drop the image in to one of your project folders in Visual Studio.
Upvotes: 1
Reputation: 13794
Follow this steps please
Select the window -> go to properties window -> select background -> click Add -> click Ok
now your image is in the resource applications it will works fine even with 2013
Upvotes: 2
Reputation: 32521
You can select an ImageBrush
as the window's Background Property
<Window.Background>
<ImageBrush ImageSource="/WpfApplication1;component/Images/IMAG0231.jpg" />
</Window.Background>
So select the Window
and press F4. Go to the Brushes part and select Background
the chose the ImageBrush
and select your image.
Upvotes: 3