费了挺长的时间,终于搞明白了修改父容器的属性的时候,不影响子容器里的所有元素的清晰度
代码如下:
<Border> <Border.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Purple" Offset="0"/> <GradientStop Color="White" Offset="0.5"/> <GradientStop Color="#FF222223" Offset="2"/> </LinearGradientBrush> </Border.Background> <Border> <Border.Background> <ImageBrush ImageSource="/HSW.BIM.Revit.FamilyEditor;component/Images/flowerImage.png" Opacity="0.2"></ImageBrush> </Border.Background> <Grid Tag="sdf" Margin="1,1,1,1" > <Grid.Background> <SolidColorBrush Color="White" Opacity="0.3"/> </Grid.Background> <Grid.RowDefinitions> <RowDefinition Height="50*" /> <RowDefinition Height="60*" /> <RowDefinition Height="80*" /> <RowDefinition Height="60" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="120" /> <ColumnDefinition Width="auto"/> <ColumnDefinition Width="22*" /> </Grid.ColumnDefinitions> <Button Content="确定" Grid.Row="3" Height="29" Margin="7,9,0,0" Name="btnOk" VerticalAlignment="Top" HorizontalAlignment="Left" Width="75" Click="btnOk_Click" Grid.Column="2" /> <Button Content="取消" Grid.Column="2" Grid.Row="3" Height="29" Margin="0,9,101,0" Name="btnCancel" VerticalAlignment="Top" Click="btnCancel_Click" HorizontalAlignment="Right" Width="75" /> <TextBlock Height="23" HorizontalAlignment="Left" Margin="49,20,0,0" Name="textBlock1" Text="族类型名称:" VerticalAlignment="Top" Grid.Row="1" /> <TextBox x:Name="txtFamilyType" Grid.Column="2" Height="23" Margin="7,20,0,0" VerticalAlignment="Top" Grid.Row="1" TextChanged="txtFamilyType_TextChanged" HorizontalAlignment="Left" Width="275" MaxLength="20" /> <TextBlock HorizontalAlignment="Left" Margin="36,17,0,8" Name="textBlock2" Text="请选择父类型:" /> <ComboBox Name="cb_familyType" ItemsSource="{Binding}" Grid.Column="2" Height="23" HorizontalAlignment="Left" Margin="8,15,0,0" VerticalAlignment="Top" Width="275" IsEditable="True" IsReadOnly="False" IsEnabled="False" SelectionChanged="cb_familyType_SelectionChanged"> </ComboBox> <TextBlock Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="84,11,0,0" Text="备注:" VerticalAlignment="Top" /> <TextBox Name="tb_description" Grid.Column="2" Grid.Row="2" Height="52" HorizontalAlignment="Left" Margin="8,12,0,0" VerticalAlignment="Top" Width="275" TextWrapping="Wrap" /> </Grid> </Border> </Border>
父容器Border修饰完Background即先加渐变,后弄图片,然后设置最大容器里Border的第一个元素即Grid里的背景色,用类SolidColorBrush纯色填充,这样就不会影响到Grid中的所有子元素
<Border>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Purple" Offset="0"/>
<GradientStop Color="White" Offset="0.5"/>
<GradientStop Color="#FF222223" Offset="2"/>
</LinearGradientBrush>
</Border/Background>
<Border.Background>
<ImageBrush ImageSource="/HSW.BIM.Revit.FamilyEditor;component/Images/flowerImage.png" Opacity="0.2"></ImageBrush>
</Border.Background>
<Grid Margin="1,1,1,1">
<Grid.Background>
<SolidColorBrush Color="White" Opacity="0.3"/>
</Grid.Background>
<button/>
<button/>
<button/>
</Grid>
</Border>