简体   繁体   中英

Text Wrap not working with WPF RichtextBox

I have a WPF User Control with a RichTextBox in it. I am consuming this User Control in one the WPF pages. Alongwith it, I am using a FlowDocumentPageViewer with a ListView in it. Later on, I am assigning the data of ListView in the RichTextBox using a FlowDocument. Everything goes well but the wrap functionality does not work in it.

On behalf of @Sumit (who asked the question)

below is the code snippet which is currently being used.

1) User Control with RichTextBox

在此处输入图片说明

2) Method to bind FlowDocument to RichTextBox

在此处输入图片说明

3)Consumer Page 在此处输入图片说明

4) Consumer Page Code behind 在此处输入图片说明

To diagnose the problem for wrap functionality, I segregated the components being used in the current XAML code into different solutions.

Please refer the following description to understand the steps followed in the analysis:-

  • A solution with List View having DataGrid (with two columns and multiple rows):- The wrap functionality was working in this solution.
  • A solution with FlowDocumentPageViewer having FlowDocument with the ListView used in the above solution:- The wrap functionality was working in this solution.
  • A solution with the User Control(referred from MultiLinha) and above FlowDocumentPageViewer. The wrap functionality was not working in this solution.

After isolating the components in this way, I observed that while integrating the User Control with FlowDocumentPageViewer the wrap functionality stopped working.

This was resolved when I put Style with property Text Wrapping set to Wrap for the FlowDocument itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM