KMC
KMC

Reputation: 20046

Transparent background goes black in WPF

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

Upvotes: 36

Views: 22887

Answers (1)

Rachel
Rachel

Reputation: 132648

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>

Upvotes: 72

Related Questions