HomeWindowsLoading the Image that is Set as Resource in Build Action

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

You May Also Like

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...