views:

220

answers:

1

I am creating a pretty standard business application in WPF. I need to use icons for the toolbars and menu items, and in a few other places. I'd like to know the answers to three (likely interrelated) things:

  • What format should I use for the images? ICO? PNG? JPG? GIF?
  • How do I store the images in my VS2008 project? As files on disk? In a RESX file? In a resource dictionary? (If in a resource dictionary, do they then also have to be on disk before the dictionary is "compiled"?)
  • Once the files are stored appropriately in my project, how best to reference them?

Thanks!

Update:

I accepted Chris Nicol's answer, but I want to clarify what I did for the record.

  1. I created a folder in my project called Images.
  2. I put my images into this folder, and made sure that their build action was "Resource".
  3. I created a ResourceDictionary XAML file called Images.xaml. Inside of this, I created an entry for each file, in the following format: BitmapImage x:Key="FooIcon" Source="Images\foo.png".
  4. I then referenced this ResourceDictionary in the usual way as needed.

My primary concern was that the resulting images be added to the DLL as resources and that they be accessible through WPF's Resource system.

+1  A: 
  1. Format - I would say .PNG from experience, though .ICO may suit your needs depending on the source and size of your original graphic.

  2. Storage - They would be resources in the project, most likely created under a folder structure. They can then be accessed through the XAML.

  3. Referencing - It depends on the architecture of your application. In the most basic solution you would have a style that would set the image source property of your toolbar (implementation depends on your control). Each toolbar would implement a style resource.

Hope that helps!

Chris Nicol