We know that the modification of the text includes: Hollow words, three-dimensional words, crossed words, shadow words, bold, tilt and so on. Here only the style of the underlined words, the position of the underlined, we can divide it into: underlined, underlined, baseline and underline. As shown in figure:
Top to bottom, underlined (overline), underlined (strikethrough), baselines (Baseline), and underscores (underline).
How to achieve it?
(1) XAML Code:
<page
xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x= "http:// Schemas.microsoft.com/winfx/2006/xaml ">
<textblock textdecorations=" strikethrough "FontSize=
" Fontfamily= "Arial" >A</TextBlock>
</Page>
The TextDecorations property can be set to: Overline, Strikethrough, Baseline, underline, or none, default to None if the TextDecorations property is not set. That is, no dash decoration.
(2) using C # code:
private void Setdefaultstrikethrough ()
{
Textblock1.textdecorations = Textdecorations.strikethrough;
}
(For simplicity, only relevant key code is listed here, and other code is not listed in C #.) TextBlock1 is the name of the TextBlock and is marked with the X:name= "TextBlock1" form in XAML
If you want a more complex point of effect, such as the need to set the color of the dash, line thickness, and so on, the following figure:
How do you make a similar effect?
Set the TextDecorations property of the TextBlock, and then set the Pen property for TextDecoration.
The following XAML code:
<page xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "http://schemas.microsoft.com /winfx/2006/xaml "> <Canvas> <textblock fontsize=" fontfamily= "Arial Black" margin= "0,0" > <
Textblock.textdecorations> <textdecoration penoffset= "Ten" penoffsetunit= "Pixel" penthicknessunit= "Pixel" > <TextDecoration.Pen> <pen thickness= "5" > <Pen.Brush> <lineargradi
Entbrush 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> Good </TextBlock> </ Canvas> </Page>