How to decrease line spacing between two lines.

3 posts, 0 answers
  1. Satya
    Satya avatar
    2 posts
    Member since:
    Jan 2008

    Posted 17 Nov 2016 Link to this post


    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. Satya
    Satya avatar
    2 posts
    Member since:
    Jan 2008

    Posted 17 Nov 2016 Link to this post

    Sorry, Forgot to attach the image. Please see attached file.
  3. Martin Ivanov
    Martin Ivanov avatar
    1410 posts

    Posted 22 Nov 2016 Link to this post

    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?

    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Back to Top