I need to dynamically change the background image applied to one of my buttons, but cannot figure out how to do this. Images are added to the project, and their assembly action is set to Resource. I tried the following:
buttonUnits.Background = new ImageBrush(new BitmapImage(new Uri("/Images/InchDOWN.png",UriKind.Relative)));
It compiles successfully, but a DirectoryNotFoundException fails and causes the message "Could not find part of the path C: \ Images \ InchDOWN.png".
I do not want the application to look for an image on disk. How to use the image as an embedded resource? I would think that this is due to changing the Build action to Embedded Resource, but how can I use this resource in the code?
c # visual-studio resources wpf
Dan Vogel Apr 21 '09 at 20:11 2009-04-21 20:11
source share