Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent background goes black in WPF

Tags:

c#

wpf

xaml

I try to create a window with rounded corner. I set Window background to transparent and set the border background to white. However on the region between the border and the window, I get black background instead of transparent.

I develop on C# WPF, VS2010 on Window 7. Below is my XAML and Screenshot.

XAML:

<Window WindowStyle="None" Background="Transparent">     <Border BorderBrush="Black" BorderThickness="1" CornerRadius="25" Background="White">         <Grid>             ... some content ...         </Grid>     </Border> </Window> 

Screenshot: enter image description here

like image 293
KMC Avatar asked Nov 11 '11 13:11

KMC


1 Answers

You also need to set AllowsTransparency="True" on your Window tag to use a Transparent Window Background

<Window WindowStyle="None"          Background="Transparent"          AllowsTransparency="True">  </Window> 
like image 147
Rachel Avatar answered Sep 20 '22 00:09

Rachel