我正在尝试制作一个小型的屏幕截图程序,我正在使用带有边框的小型WPF窗口。这应该作为“视口”功能,因此窗口内部(在边框内部)的所有内容都应该被截图。然而,当我将窗口的透明度设置为0时,我无法看到我的边框。有没有办法使我的网格完全透明,并仍然保留其周围2像素的黑色边框?
我正在尝试制作一个小型的屏幕截图程序,我正在使用带有边框的小型WPF窗口。这应该作为“视口”功能,因此窗口内部(在边框内部)的所有内容都应该被截图。然而,当我将窗口的透明度设置为0时,我无法看到我的边框。有没有办法使我的网格完全透明,并仍然保留其周围2像素的黑色边框?
不确定您是想要窗口还是仅带有边框的网格透明。
这会在窗口周围绘制边框:
<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>
这只是围绕网格绘制边框的操作:
<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>