如何设置WPF窗口的透明度颜色?

发布于 2024-12-07 12:30:03 字数 34 浏览 6 评论 0原文

有没有办法将一种特定颜色设置为整个 WPF 窗口透明?

Is there any way to set one specific color to be transparent for the whole WPF window?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

坏尐絯℡ 2024-12-14 12:30:03

你不需要。 WPF 中的透明度无法像 Winforms 中那样使用遮罩颜色 - 只需将背景设置为透明,并将AllowsTransparency 设置为 true。如果您想要不同形状的窗口,可以使用此处描述的技术:http://devintelligence.com/ 2007/10/shape-windows-in-wpf/

You don't need to. Transparency in WPF doesn't work using mask colors like in Winforms- just set the background to Transparent, and AllowsTransparency to true. If you want different shaped windows, you can use the technique described here: http://devintelligence.com/2007/10/shaped-windows-in-wpf/

晒暮凉 2024-12-14 12:30:03

我们可以制作一个透明WPF窗口使用如下所示的 XAML。

<Window x:Class="SeeThru.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="SeeThru" Height="300" Width="300"
    WindowStyle="None" AllowsTransparency="True"
    Background="Transparent">
......
</Window>

We can make a transparent WPF window by using a XAML like follows.

<Window x:Class="SeeThru.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="SeeThru" Height="300" Width="300"
    WindowStyle="None" AllowsTransparency="True"
    Background="Transparent">
......
</Window>
魔法唧唧 2024-12-14 12:30:03

不。WPF 支持 Alpha 通道透明度,而不是位图蒙版透明度。

有些人尝试解决这个问题,但仅限于每个图像。

No. WPF supports alpha-channel transparency, not bitmap mask transparency.

There are people who have attempted to work around this, but only on a per-image basis.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文