标签:str tps 9.png image lan 下划线 版权 uid article
原文:WPF编程,TextBlock中的文字修饰线(上划线,中划线,基线与下划线)的使用方法。
参考地址:https://blog.csdn.net/johnsuna/article/details/1895169
效果:
从上至下,分别为上划线(Overline),中划线(StrikeThrough),基线(Baseline),下划线(Underline)。
<TextBlock TextDecorations="Strikethrough" Text="文字"/>
?C#后台设置:
textBlock1.TextDecorations = TextDecorations.Underline;
textBlock1为控件TextBlock的名称?
<TextBlock FontSize="84"
Text="文字">
<TextBlock.TextDecorations>
<TextDecorationCollection>
<TextDecoration PenOffset="3" />
</TextDecorationCollection>
</TextBlock.TextDecorations>
</TextBlock>
<TextBlock FontSize="84"
Text="文字">
<TextBlock.TextDecorations>
<TextDecorationCollection>
<TextDecoration PenOffset="1" />
<TextDecoration PenOffset="3" />
</TextDecorationCollection>
</TextBlock.TextDecorations>
</TextBlock>
<TextBlock FontSize="84"
Text="文字">
<TextBlock.TextDecorations>
<TextDecoration PenOffset="10"
PenOffsetUnit="Pixel"
PenThicknessUnit="Pixel">
<TextDecoration.Pen>
<Pen Thickness="5"
Brush="Green" />
</TextDecoration.Pen>
</TextDecoration>
</TextBlock.TextDecorations>
</TextBlock>
<TextBlock FontSize="84"
Text="文字">
<TextBlock.TextDecorations>
<TextDecoration PenOffset="10"
PenOffsetUnit="Pixel"
PenThicknessUnit="Pixel">
<TextDecoration.Pen>
<Pen Thickness="5">
<Pen.Brush>
<LinearGradientBrush Opacity="0.8"
StartPoint="0,0.5"
EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Yellow"
Offset="0" />
<GradientStop Color="Red"
Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Pen.Brush>
<Pen.DashStyle>
<DashStyle Dashes="1,2,3" />
</Pen.DashStyle>
</Pen>
</TextDecoration.Pen>
</TextDecoration>
</TextBlock.TextDecorations>
</TextBlock>
C#后台实现:(此部分作者:大可山人)
TextDecoration myUnderline = new TextDecoration();
??? Pen myPen = new Pen();
??? myPen.Brush = new LinearGradientBrush(Colors.Yellow, Colors.Red, new Point(0, 0.5), new Point(1, 0.5));
??? myPen.Brush.Opacity = 0.8;
??? myPen.Thickness = 5;
??? myPen.DashStyle = DashStyles.Dash;
??? myUnderline.Pen = myPen;
??? myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended;
??? TextDecorationCollection myCollection = new TextDecorationCollection();
??? myCollection.Add(myUnderline);
??? textBlockGood.TextDecorations = myCollection;
?
WPF编程,TextBlock中的文字修饰线(上划线,中划线,基线与下划线)的使用方法。
标签:str tps 9.png image lan 下划线 版权 uid article
原文地址:https://www.cnblogs.com/lonelyxmas/p/10729323.html