在我的应用程序中,我希望在下面有一个透明窗口但完全不透明的子控件。但是,WPF 使所有子级透明。
请参阅下面的 XAML。正如预期的那样,网格是半透明的 50%,但其中的矩形是透明的而不是不透明的,即使考虑 opacity="1"。有什么办法可以做到这一点?
<Window x:Class="WpfApplication10.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" AllowsTransparency="True" Height="300" ResizeMode="NoResize" Width="300" WindowStyle="None" Background="Transparent" >
<Border BorderBrush="black" BorderThickness="7" CornerRadius="10">
<Grid Background="Red" Opacity="0.5" >
<Rectangle Width="100" Height="100" Fill="white" Opacity="1"/>
</Grid>
</Border></Window>
谢谢, 切利克