我试图制作一个小截屏程序,我正在制作一个带边框的小型WPF窗口。这应该作为“视口”,因此窗口内(边框内)的所有内容都应该是截图。然而,当我将窗口的透明度设置为0时,我无法看到我的边框。关于如何使我的网格完全透明,并在其周围保留2 px黑色边框的任何想法?
答案 0 :(得分:6)
不确定您是希望窗口还是只有网格透明边框。
在窗口周围绘制边框:
<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>