我有一个网格,想要将其不透明度设置为0.5。 此外,我还有一个边框,以使其成为圆角,我也希望这个边框的不透明度为0.5。 我希望所有这些操作都不会影响网格内容。 我已经成功地改变了网格的不透明度,而不影响其内容:
<Grid Grid.Column="0" Grid.Row="0" Margin="10,15,5,5" >
<Border BorderThickness="7" CornerRadius="4" >
<Grid>
<Grid.Background>
<SolidColorBrush Color="#73B2F5" Opacity="0.5"/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Button Grid.Row="1" Grid.Column="0" Width="40" Height="40" Content="Asaf"></Button>
</Grid>
</Border>
</Grid>
在上面的示例中,按钮具有完全不透明度,而网格为0.5,但边框怎么样呢?
如何使边框的不透明度为0.5,而不影响其中的网格和网格内容(所有边框子元素)?我尝试了这个,但它不起作用:
<Grid Grid.Column="0" Grid.Row="0" Margin="10,15,5,5" >
<Border BorderThickness="7" CornerRadius="4">
<Border.Background>
<SolidColorBrush Color="#73B2F5" Opacity="0.5"/>
</Border.Background>
<Grid>
<Grid.Background>
<SolidColorBrush Color="#73B2F5" Opacity="0.5"/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Button Grid.Row="1" Grid.Column="0" Width="40" Height="40" Content="Asaf"></Button>
</Grid>
</Border>
</Grid>