In WPF as well as win32, controls or child windows in general can't have color transparency.
But they can have a non rectangular region. Any shape, including holes.
Use the control's region property to change it's region. There's an example in this link on how to draw a round button.
FYI, pixels that are outside the region are NOT receiving any messages/notifications.
Examples of crazy shaped controls:
- Button shaped like a person's head.
- Spiral shape.
- 3 triangles that do not touch each other.
- Chess board - every 2nd pixel is transparent.
Also, a region is dynamic, can be changed after object creation, so your button can grow and shrink...
It's also pretty fast.
Limitations:
- No alpha blending - either opaque or fully transparent.
I wrote a function (C++/win32) that takes a control and a BMP, both have the same size, scan the BMP for a "tranparent" color (you decide which color) and remove all pixels in that color from the region of the control. This is about half a screen of code.