Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change line spacing in TextBlock

Tags:

wpf

I am using WPF, there is a TextBlock in my UserControl. The Text is very long, so I wrap it with TextWrapping = Wrap. The question is, how can I change the line spacing?

The code is something like:

<TextBlock Text="abcdefghijklmn" TextWrapping="Wrap"/> 

The output is like:

abcdefghijk lmn 

What I want is:

abcdefghijk <--increase this line spacing--> lmn 

Great Thanks.

like image 988
user1205398 Avatar asked May 12 '13 17:05

user1205398


People also ask

Is TextBlock editable?

TextBlock is not editable.

What is TextBlock?

Text block is the primary control for displaying read-only text in apps. You can use it to display single-line or multi-line text, inline hyperlinks, and text with formatting like bold, italic, or underlined.

What is TextBlock WPF?

The TextBlock control provides flexible text support for UI scenarios that do not require more than one paragraph of text. It supports a number of properties that enable precise control of presentation, such as FontFamily, FontSize, FontWeight, TextEffects, and TextWrapping.


1 Answers

Use LineHeight together with LineStackingStrategy="BlockLineHeight"

Like

<TextBlock Text="abcdefghijklmn" TextWrapping="Wrap" LineStackingStrategy="BlockLineHeight" LineHeight="30"/> 

(credz Mixer for the BlockLineHeight addition)

like image 122
Phonix Avatar answered Sep 20 '22 11:09

Phonix