My task is to create a small text editor (as a diploma), only with various features, like snippets, insert formulas, etc.

The solution is to build an application based on RichTextBox and FlowDocument's and fasten the required functionality.


Problem

I do not quite understand how a FlowDocument container breaks content into pages. Rather, at what point, for example, does the same Word understand that it’s time to move to a new page?

From which a reasonable question arises: if I want to display a large document on different visual pages on the UI, then how best to implement it? Should there be your own RichTextBox on each visual page, or is it better to write your own FlowDocument container (which will obviously be worse than the richbox itself) splitting the content into different pages?

By the way, it is believed that RichTextBox is not the most optimal control for such purposes.

    1 answer 1

    Did not do this, but I can assume that the structure should look something like this

    public class Document: IEnumerator<DocPage>, IEnumerable<DocPage> { // Реализацию интерфейсов я писать не буду // Основа тут именно IEnumerator, тебе придется определить // как разделять документ на страницы (скорее всего по высоте содержимого) // То есть то, что имеет суммарную высоту меньше высоты страницы, // а с учетом следующего объекта - больше // будет являться текущей страницей (Current), // а MoveNext будет перемещать указатель на конец текущей страницы // после последнего ее элемента } public class DocPage { // Саму страницу скорее всего нужно разбить на составляющие детали // строки или абзацы или еще что то. } 

    And in xaml, I hs what control is better to use, but it will be some ItemControl, with the panel and items you need to display pages. The items themselves will probably be of the RichTextBox type.

    • This is an interesting idea, I will try to implement something like that. But, I understand that DocPage in fact can be FlowDocument itself? It breaks the text into components, well, plus allows much more than I could do with my hands. - pe_ka
    • one
      @pe_ka, not exactly. DocPage is a model or a view model. FlowDocument will interact with DocPage as you tell it - iRumba