0

我创建了以下样式:

<Style x:Key="LinkText" TargetType="{x:Type Label}">
    <Setter Property="Label.FontFamily" Value="Verdana"/>
    <Setter Property="Label.FontSize" Value="13"/>
    <Setter Property="Label.Foreground" Value="Blue"/>
    <Setter Property="TextBlock.TextDecorations" Value="Underline"/>
</Style>

但是当我尝试在某个标签上使用它时,UnderLine 丢失了。

我在我的 UserControl 上写了下一个标签:

<Label Grid.Column="1" HorizontalAlignment="Right" Style="{StaticResource LinkText}">
 <TextBlock>some text</TextBlock></Label>

我看到除下划线属性之外的所有样式属性如何创建带下划线的标签样式?

4

1 回答 1

0

尝试使用TextBlock控件而不是Label控件。它的行为或多或少完全相同,应该允许您在文本下划线。

TextBlock.TextDecorations依赖属性属于控件,TextBlock因此您必须使用它来为文本添加下划线。

于 2012-10-04T07:54:12.803 回答