透明背景在 WPF 中变黑 [英] Transparent background goes black in WPF
本文介绍了透明背景在 WPF 中变黑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试创建一个带圆角的窗口.我将窗口背景设置为透明并将边框背景设置为白色.但是在边框和窗口之间的区域,我得到黑色背景而不是透明.
I try to create a window with rounded corner. I set Window background to transparent and set the border background to white. However on the region between the border and the window, I get black background instead of transparent.
我在 C# WPF、VS2010 上在 Window 7 上开发.下面是我的 XAML 和屏幕截图.
I develop on C# WPF, VS2010 on Window 7. Below is my XAML and Screenshot.
XAML:
<Window WindowStyle="None" Background="Transparent">
<Border BorderBrush="Black" BorderThickness="1" CornerRadius="25" Background="White">
<Grid>
... some content ...
</Grid>
</Border>
</Window>
屏幕截图:
推荐答案
您还需要在 Window
标签上设置 AllowsTransparency="True"
以使用透明窗口背景
You also need to set AllowsTransparency="True"
on your Window
tag to use a Transparent Window Background
<Window WindowStyle="None"
Background="Transparent"
AllowsTransparency="True">
</Window>
这篇关于透明背景在 WPF 中变黑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文