views:

75

answers:

1

Greetings,

I have a TreeView containing a set of TreeViewItems - Each TreeView is pretty simple (just some text, plus an image) - The images are usually folder & files icon. All good and simple...except for the fact that since the contents of images do not fit an exact square, there is some white background surrounding portions of each.

Of course, the problem then is that when drawn and then selected by the user, the unsightly white pixels of the image background get displayed (instead of being clear and blending with the highlighting), creating a rather amateur look.

It's been a few years since I've done heavy Windows GUI programming, but I recall in Win32/MFC, there used to be a single, handy value that you could set which contained the color that should not be rendered for an image (preventing this problem). But I don't know what is offered in WPF that would offer similar capabilities.

Any advice?

Thanks!

+1  A: 

Instead of using chroma key (which is so 1990's) you should convert the images to PNG or Bitmap format with proper alpha (transparency) information.

WPF will honour the alpha when it renders the images, which should take care of the white background. Because there are 256 levels (instead of the two offered by chroma key) you'll also be able to get much smoother edges as they can be properly antialiased.

GraemeF