#1,196 – Making a Window Fully Transparent
November 6, 2014 2 Comments
You can make the background of a window fully transparent by setting its Background property to Transparent, settings AllowsTransparency to true and setting WindowStyle to None.
Below is an example. Note that because WindowStyle is None, the window doesn’t have a normal border and we can’t therefore move the window around.
<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="Transparent" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen"> <StackPanel> <TextBlock Text="Topper (1937) starred Cary Grant and Constance Bennett" TextWrapping="Wrap" HorizontalAlignment="Center" Height="40" Margin="47,0"/> <Button Content="Ok, Got It" Padding="10,5" Margin="10" HorizontalAlignment="Center" Click="Button_Click"/> </StackPanel> </Window>
Here’s the window in action. (We added a handler to the button’s Click event to close the window when clicked).
Hy Sean! How can I move a form with a transparent background &
Insert “this.DragMove()” in the body of the “Button_Click1” method which is in the code-behind file.