0

i want to make an image a background to my project ,i used Imagebruch using this xaml code:

 <Window.Background>
        <ImageBrush ImageSource="C:\Users\ASUS\Documents\Visual Studio 2013\Projects\anlysis\anlysis\Images/GeneralWay.jpg"></ImageBrush>
    </Window.Background>

is there a way to use this feature without using the full path and just use image name? please help me..

Wim Ombelets
  • 5,097
  • 3
  • 39
  • 55
basel man
  • 471
  • 1
  • 5
  • 10
  • [The only time you should use tags in your title is when they are organic to the conversational tone of the title.](http://stackoverflow.com/help/tagging) – BCdotWEB May 06 '15 at 09:48

2 Answers2

0

Add GeneralWay.jpg to your project as a resource (from your Images folder) and set ImageBrush Imagesource property to the relative path of your image location i.e. <ImageBrush ImageSource="../Images/GeneralWay.jpg"/>

auburg
  • 1,373
  • 2
  • 12
  • 22
0

You can use a resource path instead. Make sure the image is registered as a resource in the project (Right click, Properties, Compile Type). Pack notation is nice as you can move it around between projects.

Source="pack://application:,,,/analysis;component/Images/GeneralWay.jpg"

Alternatively just this if you never plan to use in another project.

Source="/Images/GeneralWay.jpg"
James Lucas
  • 2,452
  • 10
  • 15
  • i made it resource and just wrote its path inside the project folder and it worked correctly thank you :D – basel man May 06 '15 at 10:01