【发布时间】:2012-09-20 06:53:37
【问题描述】:
我有一个来自设计师的样式指南,用于一个看起来像超链接的按钮,我正在尝试使用 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="> "/>
<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>
【问题讨论】:
-
在第二个 TextBlock 中添加 Margin="0,5,0,0"
-
@FlorianGl :对不起,我把你和两个 TextBlock 混淆了。查看已接受的答案。
标签: wpf xaml textblock underline