Loading the Image that is Set as Resource in Build Action

In most of the cases , we set the Build Action to “Content” for images / Media and set the Copy to Output Directory to “Copy Always” or “Copy if Newer” .

It happens that you would have set the Build Action of the Image to “Resource” and trying to get the image that is embedded . In this case the image is emdedded in your dll .

Loading the Image that is Set as Resource in Build Action

You can get the Image that is set as resource in Build Action by setting the right URL .

“/<AssemblyName;component/<Path to Image with file extension> “

private void button1_Click_1(object sender, RoutedEventArgs e)
{
Uri imageURI = new Uri("/PhoneApp3;component/StartScreen.jpg", UriKind.RelativeOrAbsolute);
BitmapImage bitMapImage = new BitmapImage(imageURI);
image1.Source = bitMapImage;
}
Loading the Image that is Set as Resource in Build Action
Loading the Image that is Set as Resource in Build Action

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...