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>
[解决办法]
使用以下代码解决:
<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>
[解决办法]