WPF,
UWP: Create transparent app window
Create a transparent app
window
A window becomes transparent
with WPF when the following settings are entered in the XAML value
<Window .. AllowsTransparency="True" Background="Transparent" WindowStyle="None" >
<Grid Background="Transparent">
..
|
Example: here the
transparent WPF window, which has a transparent background and shows only the
button and a visible border.
Complete sample code in XAML
<Window x:Class="wpf_Screenshot_App_to_Image_File.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:wpf_Screenshot_App_to_Image_File"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" AllowsTransparency="True" Background="Transparent" WindowStyle="None" >
<Grid Background="Transparent">
<Border BorderBrush="Red" BorderThickness="2"></Border>
<Button x:Name="btnScreenShot" Content="ScreenShot App to Image-File" HorizontalAlignment="Left" Margin="41,40,0,0" VerticalAlignment="Top" Width="177" Height="37"
Click="btnScreenShot_Click"
/>
</Grid>
</Window>
|