This is a migrated thread and some comments may be shown as answers.

How to decrease line spacing between two lines.

2 Answers 1502 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Satya
Top achievements
Rank 1
Satya asked on 17 Nov 2016, 11:54 AM

Hi,

I am using RadRichTextBox and filling it with XAML Data Provider.  For text construction I am using "Segoe UI" font of size 12. When I am two lines separated by Enviornement.NewLine it looks like the line spacing is more than 1. I tried to decrease the line spacing by LineSpacingType as Exact and LineSpacing to 0.75. Due to this text appearance changed and not readable. Following is the example.

                Paragraph title = new Paragraph();
                title.LineSpacingType = LineSpacingType.Exact;
                title.LineSpacing = 0.75;

 

I used SetupDocument method of XamlDataProvider to decrease the spacing. But no luck.

  e.Document.LineSpacing =1;

Note: I am using latest version of WPF Controls of Telerik.

Please Help.

 

2 Answers, 1 is accepted

Sort by
0
Satya
Top achievements
Rank 1
answered on 17 Nov 2016, 11:56 AM
Sorry, Forgot to attach the image. Please see attached file.
0
Martin Ivanov
Telerik team
answered on 22 Nov 2016, 12:51 PM
Hello Satya,

Note that when you add a new line to your string, the elements on the new line will be moved into a new paragraph. Without your set up I can't be sure if this is the issue, but it seems that the line spacing is applied only on the first paragraph created by you, but the automatically created one (after the line break), uses its default spacing setting.

In order to achieve your requirement you can try editing the default normal style of the paragraphs. This way the spacing will be set globally.
var normalStyle = this.richTextBox.Document.StyleRepository[RadDocumentDefaultStyles.NormalStyleName];
normalStyle.ParagraphProperties.LineSpacingType = LineSpacingType.Exact;
normalStyle.ParagraphProperties.LineSpacing = 30;

If this doesn't help you can share more details of your set up. For example, where you change the document? How you set the new line? How is your view model defined? What is the set up of the data provider and the rich text box control?

Regards,
Martin
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Tags
RichTextBox
Asked by
Satya
Top achievements
Rank 1
Answers by
Satya
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or