如何在WPF TextBlock中更改文本和下划线之间的距离?

问题描述 投票:3回答:3

我从设计师那里得到了一个样式指南,用于一个看起来像超链接的按钮,我正在尝试使用WPF样式尽可能地接近它。

但是我无法更改文本和下划线之间的距离。我想添加图像进行比较,但很遗憾,到目前为止我还没有获得足够的积分。

是否可以更改文字和下划线之间的距离?

这里是我到目前为止拥有的XAML代码:

<Style x:Key="LinkButton" TargetType="ButtonBase">
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Cursor" Value="Hand"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ButtonBase">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="&gt; "/>
                    <TextBlock TextDecorations="Underline">
                        <ContentPresenter/>                        
                    </TextBlock>
                </StackPanel>                 
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="Foreground" Value="{StaticResource LxGrayBrush}"/>
    <Setter Property="FontSize" Value="12"/>
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="true">
            <Setter Property="Foreground" Value="{StaticResource LxGreenBrush}"/>
        </Trigger>
    </Style.Triggers>
</Style>
wpf xaml textblock underline
3个回答
4
投票
Location

((您可能还需要通过元素语法设置Location


0
投票
分隔符:

<TextBlock> <TextBlock.TextDecorations> <TextDecoration Pen="..." Location="..."/> </TextBlock.TextDecorations> </TextBlock>

保证金:

Pen

0
投票
调整PenOffset将增加/减小文本和线条之间的距离。
© www.soinside.com 2019 - 2024. All rights reserved.