How can I change the distance between text and underline in a WPF TextBlock?
Use element syntax to add an instance of TextDecoration
to the TextBlock.TextDecorations
, then you can adjust the Location
or PenOffset
.
<TextBlock> <TextBlock.TextDecorations> <TextDecoration Pen="..." Location="..."/> </TextBlock.TextDecorations></TextBlock>
(You may need to set the Pen
via element syntax as well)
You can do this by adding a Separator between them or by setting the Margin.
Separator:
<StackPanel Orientation="Horizontal"> <TextBlock Text="> "/> <Separator Width="5" Visibility="Hidden" /> <TextBlock TextDecorations="Underline"> <ContentPresenter/> </TextBlock></StackPanel>
Margin:
<StackPanel Orientation="Horizontal"> <TextBlock Text="> " Margin="0,0,5,0" /> <TextBlock TextDecorations="Underline"> <ContentPresenter/> </TextBlock></StackPanel>