我试图制作一个小截图程序,我正在制作一个带边框的小型WPF窗口。 这应该作为“视口”,因此窗口内(边框内)的所有内容都应该是截图。 然而,当我将窗口的透明度设置为0然后我看不到我的边框时。 有关如何使我的网格完全透明,并仍然保留2 xx黑色边框的任何想法?
Im trying to make a small screenshot program, im making a small WPF window with a border. This should function as a "Viewport" so everything inside the window (within the border) should be screenshottet. How ever when i set the transparency of the window to 0 then i cant see my border. Any ideas on how to make my grid fully transparent, and still preserve a 2 px black border around it?
最满意答案
不确定您是希望窗口还是只有网格透明边框。
这会在窗口周围绘制边框:
<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" AllowsTransparency="True" WindowStyle="None" Background="Transparent" BorderThickness="2" BorderBrush="Black"> <Grid> </Grid> </Window>这只是在网格周围绘制一个broder:
<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" AllowsTransparency="True" WindowStyle="None" Background="Transparent"> <Border BorderThickness="2" BorderBrush="Black"> <Grid> </Grid> </Border> </Window>Not sure if you want the window or just the grid transparent with border.
That draws a border around the window:
<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" AllowsTransparency="True" WindowStyle="None" Background="Transparent" BorderThickness="2" BorderBrush="Black"> <Grid> </Grid> </Window>This is drawing a broder around the grid only:
<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" AllowsTransparency="True" WindowStyle="None" Background="Transparent"> <Border BorderThickness="2" BorderBrush="Black"> <Grid> </Grid> </Border> </Window>更多推荐
边框,border,make,window,电脑培训,计算机培训,IT培训"/> <meta name="descrip
发布评论