读书人

wpf里窗体如何实现半透明。Opacity如何

发布时间: 2012-04-12 15:46:35 作者: rapoo

wpf里窗体怎么实现半透明。Opacity怎么不起作用?
winform里Opacity设置一下就可以半透明了,为什么wpf里灰色?

代码如下


<Window x:Class="WpfApplication3.Window2"
? xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
? xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
? Title="Window2" Height="300" Width="300" Opacity="0.5" AllowsTransparency="False">
</Window>

[解决办法]
使用以下代码解决:

XML code
<Window   x:Class="ForumProjects.MainWindow"   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   Title="MainWindow" Height="800" Width="600"   AllowsTransparency="True" Background="#AA000000" WindowStyle="None">    <StackPanel>        <Button Width="100" Height="40">Hello</Button>    </StackPanel></Window>
[解决办法]
探讨

使用以下代码解决:

XML code

<Window
x:Class="ForumProjects.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
……

[解决办法]
1.AllowsTransparency="True"
2.WindowStyle="None" 缺1不可
[解决办法]
AllowsTransparency="True" WindowStyle="None"

读书人网 >CAD教程

热点推荐