LineSpacing in WPF RichTextBox - wpf

I have written a text editor in WPF based on the WPF RichTextBox.
Everything works well. With BOLD, ITALIC etc., FontSize, FontFamily, TextAlignment and Indentation there are no problems.
But:
LineSpacing does not work! I can set the LineSpacing with Paragraph.LineHeight. When I save the text file in RTF format and load it again, the LineSpacing disappears. When loading, the corresponding RTF statement '\slnnn' is deleted.
If I load an RTF file from another text editor, the LineSpacing disappears also.
I know that I don't have the problem if I save the content of the RichTextBox as an XAML package and load it again. But then I am no longer compatible with other TextEditors.
Does anyone know a solution?

Related

Does WPF Textbox respect Unicode BIDI controls like LRI/RLI?

I need to display English + Hebrew text mixed in a text box. I embed each language with the appropriate RLI/LRI/PDI controls but it seems that it doesn't make any difference. Depending on the content, things end up out of order, like if the BIDI controls are being ignored.
To check that my BIDI controls are placed correctly, I take the same text displayed in the textbox and put it in Clipboard. Pasting it to notepad or word displays the text in the expected order while on the textbox it isn't.
Can someone confirm if WPF textbox should respect these Unicode BIDI controls?
Am I missing any special setting on the textbox so it takes it into consideration?

WPF Markup Control

I have a string of text that I need to display. I currently display it in a textbox.
My requirements have changed and now I need to display parts of this string in Red.
I have looked and all I can see for displaying text in several colors is a WebBrowser or RichTextbox. Both of these are more complex then I was hoping to use.
I can format the text string in any way (using any kind of markup).
Is there some kind of simple markup control out there for wpf? (Note: This will be going on a datagrid that can have many hundreds of rows, so it cannot be a memory/processing intensive control.)
You can use a TextBlock if it doesn't need to be edited.
From above link:
TextBlock is designed to be lightweight, and is geared specifically at integrating small portions of flow content into a user interface (UI). TextBlock is optimized for single-line display, and provides good performance for displaying up to a few lines of content.
TextBlock is not optimized for scenarios that need to display more than a few lines of content; for such scenarios, a FlowDocument coupled with an appropriate viewing control is a better choice than TextBlock, in terms of performance. After TextBlock, FlowDocumentScrollViewer is the next lightest-weight control for displaying flow content, and simply provides a scrolling content area with minimal UI. FlowDocumentPageViewer is optimized around "page-at-a-time" viewing mode for flow content. Finally, FlowDocumentReader supports the richest set functionality for viewing flow content, but is correspondingly heavier-weight.
Modified example from link showing Red Text:
<Grid>
<TextBlock TextWrapping="Wrap" >
<Bold>TextBlock</Bold> is designed to be <Italic>lightweight</Italic>
and is geared <Run Foreground="Red">specifically</Run> at integrating
<Italic>small</Italic> portions of flow content into a UI.
</TextBlock>
</Grid>
AvalonEdit should do what you want. There is a Nuget package for it. See here also:
http://www.codeproject.com/Articles/42490/Using-AvalonEdit-WPF-Text-Editor
Also, if the text is not being edited, I think you should probably use something like a ListBox with custom item templates -- especially if the entire line is to be highlighted.

Binding HTML content to a "RichHTMLTextBlock" in XAML

I am having a WPF application, in which i am using RichTextBox and binding it to a field in the database which contains the data as a HTML text. Also i applied TextFormatter="{StaticResource HtmlFormatter}" for the RichTextBox. Now if in the field i have a paragraph with some html styles applies like font color, font size etc they are supposed to appear in the same style.But i am not able to see the font size in the application, though font style and font color are applied.
Can anybody help on this ?
Thanks in advance!!!

Display RTF with DocumentViewer

I need to display a RTF document in my WPF Application. I think DocumentViewer is the best choice because of search box and toolbar with print, zoom and so on. The problem is that I don't realize how to convert RTF format to FixedDocument. Any idea?
Thanks

In WPF how to create a textblock with copy text option (OR) a text box with text trimming option

In WPF how to create a textblock with copy text option (OR) a text box with text trimming option. Any control template needed? If yes, please let us know hpw to build it.
Please help.
Sukan
First part is a duplicate of Any way to make a WPF textblock selectable?.
TextTrimming is a property in the TextBox.

Resources