How to set the window to transparent in wpf
Zhou yinhui
In wpf, you must set the window to transparent. In addition to setting the Alpha component of the window background color to 0,You must also set the AllowsTransparency attribute of the window to true..
Note that there is a default Grid Object named LayoutRoot in the form (window). You should set the Alpha component of the background color to 0.
Here is a Demo: it shows a circular irregular form. You can copy the following code to XamlPad to view the effect:
<Window
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Xml: lang = "zh-CN"
X: Name = "Window"
Title = "Window1"
Width = "420" Height = "287" Visibility = "Visible" ResizeMode = "NoResize" SizeToContent = "Manual" WindowStyle = "None" Background = "#00 FFFFFF" AllowsTransparency =" true ">
<Grid x: Name = "LayoutRoot" OpacityMask = "{x: Null}" Background = "#00000000">
<Ellipse Fill = "# FFB7ECDA" Stroke = "# FF172A9C" StrokeThickness = "3" HorizontalAlignment = "Right" Margin = "0, 0, 138 "VerticalAlignment =" Bottom "Width =" 138 "Height =" "/>
</Grid>
</Window>