Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
245
Default to single line spacing.
posted

I would like to be able to set the default action to single line spacing.  I have found some code as follows that allows you to change the line spacing of a selection.  This code wont work in my case because when the text editor is loaded there is no initial selection.

ParagraphSettings paragraphSettings = new ParagraphSettings();

ParagraphSpacingSettings paragraphSpacingSettings = new ParagraphSpacingSettings();

paragraphSettings.WordWrap = true;

paragraphSettings.Spacing = paragraphSpacingSettings;

paragraphSpacingSettings.LineSpacing = new LineSpacing(1);

string error;

_textEditor.Document.ApplyParagraphSettings(_textEditor.Selection.DocumentSpan, paragraphSettings, out error);

Parents
  • 3520
    Offline posted

    Hello Aaron,

     

    When the editor is loaded with a new empty document or new paragraphs are added to some document the settings applied on the new content are the Document’s default settings. In order to apply LineSpacing of 1 line for all paragraphs in the document you need to set these spacing settings to the default ParagraphSettings of the RootNode’s DocumentSettings object as follows:

     

    Editor.Document.RootNode.Settings = new DocumentSettings();

    Editor.Document.RootNode.Settings.DefaultParagraphSettings = paragraphSettings;

     

    In the attached sample application I’m using this approach to achieve your requirements.

    Please, let me know if you need further assistance on the matter.

     

    RTE_DefaultSettingsSample.zip
Reply Children