I have some images added to my solution, right now it is under the folder images\\flowers\\rose.png inside the solution explorer. I want a way to dynamically load this imag
I had some problems to find the exact syntax for the URI, so see below more details :
If your image (myImage.png
) is located in a subfolder "images" (from the root directory) , the exact syntax is :
image.Source = new BitmapImage(new Uri(@"pack://application:,,,/images/myImage.png", UriKind.Absolute));
If your image is in the subfolder images/icon/
(from the root directory) , the syntax is :
image.Source = new BitmapImage(new Uri(@"pack://application:,,,/images/icon/myImage.png", UriKind.Absolute));
"pack://application:,,,
does not change.For more information: see here.