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



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

你不需要。WPF中的透明度不像在Winforms中那样使用蒙版颜色——只需将背景设置为Transparent,并将allowtransparent设置为true。如果您想要不同形状的窗口,您可以使用这里描述的技术:http://devintelligence.com/2007/10/shaped-windows-in-wpf/

我们可以使用下面的XAML来创建一个透明的WPF窗口。

<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>

No。WPF支持alpha通道透明,不支持位图掩码透明。

有人试图解决这个问题,但只是在每个图像的基础上。

最新更新