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

  • 相关阅读:
    ZOJ 4097 Rescue the Princess
    最大值最小化 最小值最大化
    SD第九届省赛B题 Bullet
    Euler Circuit UVA
    bzoj 1878
    随笔
    BZOJ
    主席树模板
    AC自动机模板
    BZOJ
  • 原文地址:https://www.cnblogs.com/FaDeKongJian/p/3161904.html
Copyright © 2011-2022 走看看