带边框的透明窗口(Transparent window with a border)

编程入门 行业动态 更新时间:2024-10-21 06:08:53
边框的透明窗口(Transparent window with a border)

我试图制作一个小截图程序,我正在制作一个带边框的小型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

本文发布于:2023-08-07 20:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465569.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:边框   透明   窗口   border   window

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!