Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make running WPF application window transparent?

Tags:

windows

wpf

I have a piece of AutoHotKey script that allows me to set transparency on an active window but it does not work with WPF application like Powershell ISE.

Is there a way to do that?

EDIT: As is stated in the question I need to do that on a running WPF app like Powershell ISE.

like image 265
Piotr Owsiak Avatar asked Oct 31 '25 10:10

Piotr Owsiak


2 Answers

Set this in Window element

 AllowsTransparency="True" WindowStyle="None" Background="Transparent"
like image 110
Maximus Avatar answered Nov 03 '25 09:11

Maximus


Hi WPF is based on Direct3D, and is a bit different from win32 and forms which is based on GDI/GDI+.

In WPF you do this in your xaml(see example by maximus) or create your own window style.

There is a post here on how you should do this in WPF.

Another slightly related question.

A style :

<Style TargetType="Window" x:Key="TransparentWindowStyle">
    <Setter Property="WindowStyle" Value="None"/>         
    <Setter Property="AllowsTransparency=" Value="True"/>
    <Setter Property="Background" Value="Transparent"/>
</Style>

Skip the x:Key and it will be applied to all windows or you have to place in app.xaml or a place where it is shared, and apply it to the window. A bit overkill for just 3 properties, but handy if you are going to do other changes, that should be applied to multiple windows.

Hope it helps,

Stian

like image 24
Stígandr Avatar answered Nov 03 '25 07:11

Stígandr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!