Change Background image in WPF using C# -


this question has answer here:

i'd change background image of wpf application button. know how using windowsforms, in wpf failed. found solution already, solution copy background images output folder next application.exe not solution desire. have images stored inside application.

can explain me detailed need [how add images program, resource-properties, how access them in c#....]. seems stupid set correctly :p

thanks in advance

firstly, add folder solution (right click -> add -> folder), name "resources" or useful.

then, add desired image folder (right click on folder -> add -> existing item).

once it's been added, if click on image , open properties window (alt+enter), you'll see build action set resource , copy output directory set do not copy.

you can reference image in c# using following code:

this.background = new bitmapimage(new uri(@"pack://application:,,,/yourapp;component/yourfolder/yourimage.png")); 

or in xaml:

<image source="pack://application:,,,/yourapp;component/yourfolder/yourimage.png" ... /> 

or:

<image source="/yourapp;component/yourfolder/yourimage.png" ... /> 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -