【发布时间】:2011-10-03 13:22:50
【问题描述】:
有没有办法将一种特定颜色设置为对整个 WPF 窗口透明?
【问题讨论】:
标签: c# .net wpf window transparency
有没有办法将一种特定颜色设置为对整个 WPF 窗口透明?
【问题讨论】:
标签: c# .net wpf window transparency
你不需要。 WPF 中的透明度不适用于 Winforms 中的蒙版颜色 - 只需将背景设置为透明,并将 AllowsTransparency 设置为 true。如果你想要不同形状的窗户,你可以使用这里描述的技术:http://devintelligence.com/2007/10/shaped-windows-in-wpf/
【讨论】:
我们可以使用如下的 XAML 创建一个transparent WPF window。
<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>
【讨论】:
没有。 WPF 支持 alpha 通道透明度,而不是位图蒙版透明度。
有些人尝试过work around this,但仅限于每张图片。
【讨论】: