zoukankan      html  css  js  c++  java
  • wpf textblock 会覆盖 button里面字体样式的解决方法 还有button的style覆盖。。datepicker里面的按钮的style

    。(button使用contont写的时候) 当。button使用 <button.content><textBlock/></button.content>依然会覆盖

     这段代码能消除全局textblock对button的影响

     <DataTemplate DataType="{x:Type System:String}">
            <TextBlock Text="{Binding}">
                <TextBlock.Resources>
                    <Style TargetType="{x:Type TextBlock}"/>
                </TextBlock.Resources></TextBlock>
        </DataTemplate>
    View Code

     button  style

    <Style TargetType="Button">
            <Setter Property="Foreground" Value="Blue"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border CornerRadius="5" BorderBrush="Black"  BorderThickness="1">
                            
                              
                                <ContentPresenter Grid.Row="1" Margin="3">
                                    <ContentPresenter.Resources>
                                        <Style  TargetType="{x:Type TextBlock}">
                                            <Setter Property="Foreground" Value="Blue"/>
                                        </Style>
                                    </ContentPresenter.Resources>
                                </ContentPresenter>
                          
                            
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    View Code

    textblock style

     <Style  TargetType="{x:Type TextBlock}">

            <Setter Property="Foreground" Value="Red"/>
        </Style>

    这样。。button里面的字是蓝色。。textblock里面是红色

    还有button的style覆盖。。datepicker里面的按钮的style

  • 相关阅读:
    5.常见类和API
    4.异常
    3.面向对象
    2.控制语句和数组
    1.初始java 数据类型 运算符
    C#设计模式——桥接模式
    C#设计模式——适配器模式
    C#设计模式——原型模式
    C#设计模式——建造者模式
    C#设计模式——抽象工厂模式
  • 原文地址:https://www.cnblogs.com/FaDeKongJian/p/3161904.html
Copyright © 2011-2022 走看看