RSM
RSM

Reputation: 15118

How do I add an image to my application

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

Answers (3)

Patrick Y
Patrick Y

Reputation: 853

Drag and drop the image in to one of your project folders in Visual Studio.

Upvotes: 1

BRAHIM Kamel
BRAHIM Kamel

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

enter image description here

Upvotes: 2

Hossein Narimani Rad
Hossein Narimani Rad

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.

enter image description here

Upvotes: 3

Related Questions