[英]Wpf withing transparent grid with opacity = “0.32” Assign Background Color/Image to Buttons and TextBox
我有一個opacity =“ 0.32”的網格,它的工作效果很好,但是現在我想添加一些控件,例如帶有一些背景純色的 文本框和按鈕 ,但是它也得到了我這里不需要的相同的不透明度比率。 有什么幫助嗎? 提前致謝。
<Grid Margin="0,1,0,2" Grid.Row="1" Grid.Column="1"
Background="#06090b" Opacity="0.25">
<Button x:Name="btnLogin" Content="Sign in" Foreground="White"
Margin="40,264,40,0" VerticalAlignment="Top" Height="60"
Click="btnLogin_Click" FontSize="18" FontWeight="Medium"
BorderThickness="1" BorderBrush="{x:Null}" Background="Blue"
Panel.ZIndex="1">
</Button>
</Grid>
我在評論中的意思是,您實際上不需要ZIndex東西。
您有兩種選擇:
1)使用Alpha顏色,現在注意背景長度為8個字符(前2個為Alpha或不透明度)
<Grid Margin="0,1,0,2" Grid.Row="1" Grid.Column="1"
Background="#8006090b">
<Button x:Name="btnLogin" Content="Sign in" Foreground="White"
Margin="40,264,40,0" VerticalAlignment="Top" Height="60"
Click="btnLogin_Click" FontSize="18" FontWeight="Medium"
BorderThickness="1" BorderBrush="{x:Null}" Background="Blue">
</Button>
</Grid>
2)僅將不透明度設置為背景
<Grid Margin="0,1,0,2" Grid.Row="1" Grid.Column="1" >
<Grid.Background>
<SolidColorBrush Color="#06090b" Opacity=".25"/>
</Grid.Background>
<Button x:Name="btnLogin" Content="Sign in" Foreground="White"
Margin="40,264,40,0" VerticalAlignment="Top" Height="60"
Click="btnLogin_Click" FontSize="18" FontWeight="Medium"
BorderThickness="1" BorderBrush="{x:Null}" Background="Blue">
</Button>
</Grid>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.