Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5989459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:06:15+00:00 2026-05-22T23:06:15+00:00

I am trying to retrieve the image from resource file and tryin to bind

  • 0

I am trying to retrieve the image from resource file and tryin to bind it to the datagrid of my WPF application.

The datagrid is somewhat like this:

<DataGridTemplateColumn Header="Image" Width="45">
  <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <Image  Source="{Binding Path=Icon}" />
                    </DataTemplate>
 </DataGridTemplateColumn.CellTemplate>

And Image is a property of type image of my MVVm class like this:

 public Image Icon
    {
        get { return _licenseImage; }
        set { _licenseImage = value;
        PropertChanged("Icon");}
    }

And in the code behind Im tryin to do something like this to get image from resource file and tryin to bind it to datagrid column.

ResourceManager resourceManager = 
        new ResourceManager("Resources.Images", Assembly.GetExecutingAssembly());
BitMap bitmap = resourceManager.GetObject("okimage") as BitMap;

Image image = bitmap;
return image;

I can see that image is populated but it is not displaying in the grid.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:06:16+00:00Added an answer on May 22, 2026 at 11:06 pm

    You should bind to an ImageSource instead of Image.

    we use this helper class:

    public static class ImageSourceHelper
    {
        public static ImageSource GetResourceImage(string resourcePath)
        {
            return GetResourceImage(Assembly.GetCallingAssembly(), resourcePath);
        }
    
        public static ImageSource GetResourceImage(Assembly resourceAssembly, string resourcePath)
        {
            if (string.IsNullOrEmpty(resourcePath)) return null;
    
            var assembly = resourceAssembly.GetName().Name;
            const string uriFormat = "pack://application:,,,/{0};component/{1}";
    
            if (!UriParser.IsKnownScheme("pack")) new System.Windows.Application();
    
            var uri = new Uri(string.Format(uriFormat, assembly, resourcePath), UriKind.RelativeOrAbsolute);
    
            return BitmapFrame.Create(uri);
        }
    
        public static ImageSource ConvertFromGdiBitmap(Bitmap bitmap)
        {
            return Common.SystemAbstraction.Media.ImageConverter.ConvertToBitmapSource(bitmap);
        }
    
        public static Bitmap ConvertToGdiBitmap(ImageSource imageSource)
        {
            return Common.SystemAbstraction.Media.ImageConverter.ConvertToBitmap(imageSource as BitmapSource);
        }
    }
    

    It creates an ImageSource from Bitmap or resource images.

    Usage is

    img.Source = ImageSourceHelper("Path/To/Your/Image.png");
    

    or

    var resourceAssembly = // get resource assembly...
    img.Source = ImageSourceHelper(resourceAssembly, "Path/To/Your/Image.png");
    

    if the image is contained in an other assembly than the currently calling assembly.

    The path of your image is the path starting at the project file root of your assembly.
    Say you have an folder images your path will be "images/somepicture.png".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to retrieve an image from an Embedded resource, and displaying it
I'm trying to retrieve a file from a server using SFTP (as opposed to
I am trying to use ResourceBundle#getStringArray to retrieve a String[] from a properties file.
I am trying to retrieve an image from SQL Server (yes, data type is
I'm trying to save a file (pdf or image) uploaded from a form into
I'm trying to write a PNG file from a image retrieved from the web.
I'm trying to retrieve N number of items from an XML file using simpleXML
I am trying to retrieve JSON data from an external text file using a
I'm trying to retrieve an XML stream from a URL. For most URLs my
I'm trying to retrieve data from an SQL Server 2000 server, and place into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.