Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Runtime-error in wpf with Window.AllowsTransparent set to true

Tags:

wpf

.net-4.0

I get an exception thrown at runtime when I set AllowsTransparency="True" I get an exception saying the WindowStyle can not be set to None if AllowsTransparency is set to true. Even if I explicitly say that WindowStyle is set to SingleBorder I get this error. However, if I set WindowStyle to SingleBorder and remove the AllowsTransparency-tag, I get no error, and the top of the window (the icon, name and close, minimize and maximize-buttons) disappears. Anyone knows what can cause this? Or is it just a bug in .Net 4.0 rc?

[Edit]
I've tried this in VS2008 too, and I get the same results. What I wan't to achieve is a simple window where I draw the window myself and leave nothing up to the system, however, things like minimizing and maximizing must still work.

like image 894
Alxandr Avatar asked Nov 23 '25 12:11

Alxandr


1 Answers

The error should be the opposite so you're either running into a bug or mis-reading the error message. Any time you have AllowsTransparency="True" the only valid WindowStyle value is None. Any of the others add OS dependent window chrome which can't be forced to have transparency in its client area.

like image 143
John Bowen Avatar answered Nov 26 '25 07:11

John Bowen



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!