Search code examples
devexpressrichedit-control

Render page breaks in DevExpress RichTextEdit


I want to be able to add and remove page-breaks to a RichEditControl element.

I understand that it's possible to add the page break by pressing Ctrl + Enter, but it's impossible for the user to see the page break and remove it, as it currently looks like it's a simple new line.

I tried to use the DXRichEditFormattingMarkVisibilityOptions to display a separator, thinking it would display the page break, without luck:

<d:RichEditControl ActiveViewType="Simple"
                   ShowBorder="False" Background="{x:Null}"
                   AutoSizeMode="Vertical" LayoutUnit="Document"
                   CommandBarStyle="Empty" BarManager="{TemplateBinding BarManager}">
    <d:RichEditControl.FormattingMarkVisibilityOptions>
        <d:DXRichEditFormattingMarkVisibilityOptions Separator="Visible"/>
    </d:RichEditControl.FormattingMarkVisibilityOptions>
</d:RichEditControl>

Is there any way to render the page break in the RichEditControl and let it be easy to be removed by the user?


Solution

  • To display the Page Break character, you need to execute a command that display all hidden characters (such as paragraphs, spaces and tabs) and force these other characters to be hidden back, letting just the page break being displayed.

    var command = new ToggleShowWhitespaceCommand(_richEditControl);
    command.Execute();
    

    Then you can apply this to the style of the control or alter directly via code:

    <d:RichEditControl.FormattingMarkVisibilityOptions>
        <d:DXRichEditFormattingMarkVisibilityOptions HiddenText="Hidden" 
            ParagraphMark="Hidden" Space="Hidden" TabCharacter="Hidden"/>
    </d:RichEditControl.FormattingMarkVisibilityOptions>