Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Window Transparency (including Non-Client Area)

Is there any way to make a WPF window transparent without losing the non-client area (borders, title bar, close/minimise/maximise buttons)?

Setting 'AllowsTransparency' to 'true' requires that 'WindowStyle' be set to 'None' (as explained in this answer), which removes the non-client area.

One of the WPF developers blogged about how transparent windows work in WPF, and why it would have been difficult to implement support for non-client area transparency.

No matter what your window styles may suggest, transparent WPF windows do not have any visible non-client area. This is fine for many scenarios where the intent is to create a custom window shape, but it can be annoying for people who just want to "fade in" a normal window.

A WPF-only solution, then, seems out of the question.

Calling the native SetLayeredWindowAttributes function and passing a WPF window's handle and LWA_ALPHA has no effect, as expected.

The only other approach I can think of is hosting WPF content within a Win32 (or possibly WinForms) window. I suspect trying to do this will result in airspace issues, however.

WPF layered windows have different capabilities on different operating systems ... WPF does not support transparency color keys, because WPF cannot guarantee to render the exact color you requested, particularly when rendering is hardware-accelerated.

I'm not sure if I'm reading the above correctly, but it sounds like trying to host WPF content featuring transparency is not possible.

Any ideas?

Transparent Notepad2 Window

like image 574
Quppa Avatar asked Jan 27 '11 16:01

Quppa


2 Answers

You can customize non-client area using library from ms called WPF Chrome. Check this article: 'Custom Window Chrome'.

With this library you can make chrome transparent and change many more things.

like image 109
bartosz.lipinski Avatar answered Nov 10 '22 22:11

bartosz.lipinski


Fluidkit has an implmentation of a glass window, which I think is what you're after.

like image 2
Joel Lucsy Avatar answered Nov 10 '22 20:11

Joel Lucsy