當您將不透明度設置爲WPF中的Grid
時,所有子元素都顯示爲繼承其Opacity
。你怎麼能有一個子元素不繼承父母的不透明?如何覆蓋WPF中父控件的不透明度?
例如,以下父網格中間有一個子網格,背景設置爲紅色,但由於父級的不透明度,背景顯得帶粉紅色。我想孩子電網有一個堅實的顏色,不透明的背景:
<Grid x:Name="LayoutRoot">
<Grid Background="Black" Opacity="0.5">
<Grid.RowDefinitions>
<RowDefinition Height="0.333*"/>
<RowDefinition Height="0.333*"/>
<RowDefinition Height="0.333*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.333*"/>
<ColumnDefinition Width="0.333*"/>
<ColumnDefinition Width="0.333*"/>
</Grid.ColumnDefinitions>
<-- how do you make this child grid's background solid red
and not inherit the Opacity/Transparency of the parent grid? -->
<Grid Grid.Column="1" Grid.Row="1" Background="Red"/>
</Grid>
</Grid>
。純色筆刷的竅門!並歡迎來到StackOverflow \(* _ *)/ – 2010-04-16 18:49:09
您是否有鏈接到實施此網站的網站?我試圖在純html/css3中覆蓋不透明,並且真的很想看到這種方法的結果html。 – 2012-02-07 02:02:46
太棒了!很遺憾,VS沒有內置的方法來區分繼承父類的不透明性。這適用於多個網格,我已經實現了這種技術,以獲得具有正常不透明度內容的半透明TabControl。 – 2014-01-07 17:01:33