Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 带透明栅格的Wpf,不透明度=”;0.32“;为按钮和文本框指定背景色/图像_C#_Wpf - Fatal编程技术网

C# 带透明栅格的Wpf,不透明度=”;0.32“;为按钮和文本框指定背景色/图像

C# 带透明栅格的Wpf,不透明度=”;0.32“;为按钮和文本框指定背景色/图像,c#,wpf,C#,Wpf,我有一个不透明度为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="Whit

我有一个不透明度为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或不透明)


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>


不要设置网格的不透明度,尝试将不透明度设置为网格的背景。您必须为控件设置Z索引感谢您的评论,但我仍然被困在这里,这是我的代码片段,谢谢我得到了解决方案@bto.rdz
<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>