14
在我的應用程序中,我希望有一個透明的窗口,但下面是完全不透明的兒童控件。但是,WPF讓所有的孩子都透明。WPF中透明的不透明元素
請參閱下面的XAML。如預期的那樣網格是半透明的50%,但其中的矩形是透明的而不透明的,即使認爲不透明度=「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>
感謝, cellik
謝謝,這個答案真的有用! – ariso 2009-10-29 13:48:14