zoukankan      html  css  js  c++  java
  • wpf 父控件透明子控件不透明

    在wpf开发中遇到子控件会继承父类控件属性的问题,

    例如:

    <StackPanel  Orientation="Horizontal" Grid.Row="1" Background="Black" Opacity="0.3">
                                                <Label Content="{Binding Id}"  Foreground="White"  VerticalAlignment="Center"></Label>
                                                <Label Content="{Binding Name}" Foreground="White" VerticalAlignment="Center"></Label>
                                            </StackPanel>

    此时两个Label都会继承stackPanel的Opacity属性,如果想要不继承透明属性,这时候需要用到笔刷,代码如下:

    复制代码
    <SolidColorBrush Color="Black" Opacity=".3" x:Key="OpacityBrush"/>
    
    <StackPanel  Orientation="Horizontal" Grid.Row="1" Background="{StaticResource OpacityBrush}">
                                                <Label Content="{Binding Id}"  Foreground="White"  VerticalAlignment="Center"></Label>
                                                <Label Content="{Binding Name}" Foreground="White" VerticalAlignment="Center"></Label>
                                            </StackPanel>
    复制代码
  • 相关阅读:
    010 Editor无限制免费安装注册破解图文教程(破解补丁)
    请求设置
    请求方法
    Session
    Config
    Model
    模板2
    模板语法
    动态路由
    Put和Delete
  • 原文地址:https://www.cnblogs.com/bruce1992/p/14184518.html
Copyright © 2011-2022 走看看