#1,195 – Making a Window Partially Transparent

You can use an alpha value when setting a background color to make the background of a control partially transparent.  (E.g. Making a tooltip partially transparent).

You can make the background of a Window transparent, or partially transparent, by doing three things:

  • Set the Background to Transparent or use a background that is partially transparent
  • Set the AllowsTransparency property to true
  • Set the WindowStyle to None

The WindowStyle must be set to None when setting AllowsTransparency to true.

Here’s an example:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Transparent"
        Height="190" Width="268"
        Background="#D5F0F0FF"
        AllowsTransparency="True"
        WindowStyle="None">

    <StackPanel>
        <Button Content="Click Me"
                Padding="10,5" Margin="10"
                HorizontalAlignment="Center"/>
    </StackPanel>
</Window>

We now get a window that doesn’t include a border (so we can’t move it), but whose background is partially transparent.  The controls within a transparent window are opaque and all work fine.

1195-001

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a comment