PenOffset就是设置下划线与字段的距离
<TextBlock>
<TextBlock.TextDecorations> <TextDecorationCollection>
<TextDecoration PenOffset="3"/>
</TextDecorationCollection>
</TextBlock.TextDecorations>
</TextBlock>
如果你不需要设置下划线与字段之间的距离
<TextBlock Text="这是带下划线的文本" TextDecorations="Underline"/>
如果你不需要设置下划线与字段之间的距离,并且要在后台处理
TextBlock textBlock = new TextBlock();
textBlock.Text = "这是带下划线的文本";
TextDecorationCollection textDecorations = new TextDecorationCollection();
textDecorations.Add(TextDecorations.Underline);
textBlock.TextDecorations = textDecorations;
本文详细探讨了TextDecorationPenOffset属性在文本装饰中的作用,解释了其设置方法和影响,通过实例展示了如何使用该属性来改变文本装饰的位置,从而提升UI设计的精细度。
1906





