【问题标题】:How to create following styles in wpf?如何在 wpf 中创建以下样式?
【发布时间】:2016-03-29 09:51:54
【问题描述】:

您如何设置如下所示的按钮内容样式?对于样式 1,使用文本块和运行似乎很容易,但样式 2,我想知道如何实现这一点。

【问题讨论】:

    标签: wpf xaml styles


    【解决方案1】:

    你可以用offset做到这一点

    <TextBlock FontSize="72">
        <Run Foreground="Gray" Text="It" /><Run Text="e">
            <Run.Foreground>
                <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                    <GradientStop Color="Gray" Offset="0"/>
                    <GradientStop Color="Gray" Offset="0.5" />
                    <GradientStop Color="Red" Offset="0.5" />
                    <GradientStop Color="Red" Offset="1" />
                </LinearGradientBrush>
            </Run.Foreground>
        </Run><Run Text="m" Foreground="Red" /><Run Text=" 1">
            <Run.Foreground>
                <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                    <GradientStop Color="Red" Offset="0"/>
                    <GradientStop Color="Red" Offset="0.5" />
                    <GradientStop Color="Gray" Offset="0.5" />
                    <GradientStop Color="Gray" Offset="1" />
                </LinearGradientBrush>
            </Run.Foreground>
        </Run>
    </TextBlock>
    

    参考:Foreground colour of textblock based on position of part of the letter

    【讨论】:

      猜你喜欢
      • 2014-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-20
      • 1970-01-01
      • 2014-04-24
      • 1970-01-01
      相关资源
      最近更新 更多