我有一个带有漂亮背景图片的WPF应用程序。但是,当我在表单中放置一些元素时,我希望它们不是那么透明。
例如简单的分组框:
<GroupBox x:Name="LocationGroup" Grid.Column="1" Grid.Row="1" Header="Location" HorizontalAlignment="Left" Height="100" Margin="10,90,0,0" VerticalAlignment="Top" Width="734">
<Grid Margin="1,1,1,1">
<Label Content="Location" HorizontalAlignment="Left" Margin="5,5,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="LocationCombo" HorizontalAlignment="Left" Margin="5,36,0,0" VerticalAlignment="Top" Width="100"
DisplayMemberPath="LocationDescr" SelectedValuePath="LocationNr" SelectedValue="{Binding Path=Location}">
</ComboBox>
</Grid>
</GroupBox>
我尝试设置组框(和网格)的不透明度属性,但是它只会影响标签和组合框的不透明度,而不会影响背景。
我在寻找什么,就像下面链接的图片中右侧的元素一样:
答案 0 :(得分:0)
这是实现它的一种方法:
<Grid>
<Grid.Background>
<ImageBrush ImageSource="path\to\backgroundimage" Stretch="UniformToFill"/>
</Grid.Background>
<Grid Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" Height="100" Width="400" Margin="10,90,0,0" VerticalAlignment="Top">
<Grid Background="White" Opacity="0.5"></Grid>
<GroupBox x:Name="LocationGroup" Header="Location">
<Grid Margin="1,1,1,1">
<Label Content="Location" HorizontalAlignment="Left" Margin="5,5,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="LocationCombo" HorizontalAlignment="Left" Margin="5,36,0,0" VerticalAlignment="Top" Width="100"
DisplayMemberPath="LocationDescr" SelectedValuePath="LocationNr" SelectedValue="{Binding Path=Location}">
</ComboBox>
</Grid>
</GroupBox>
</Grid>
</Grid>