【问题标题】:How to set transparency color of the WPF Window?如何设置 WPF 窗口的透明度颜色?
【发布时间】:2011-10-03 13:22:50
【问题描述】:

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

【问题讨论】:

    标签: c# .net wpf window transparency


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      我们可以使用如下的 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>
      

      【讨论】:

        【解决方案3】:

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

        有些人尝试过work around this,但仅限于每张图片。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-06-26
          • 1970-01-01
          • 2020-08-18
          • 1970-01-01
          • 2011-03-26
          • 1970-01-01
          • 2023-03-10
          • 1970-01-01
          相关资源
          最近更新 更多