I'm making a text editor with WPF. I'm using a FlowDocument element wrapped in a RichTextBox. My goal is to add extra information to each new paragraph that is created at runtime (see example). As in, each time the user creates a new paragraph, this extra information is displayed.
<RichTextBox x:Name="richText">
<FlowDocument IsOptimalParagraphEnabled="True"
IsHyphenationEnabled="True"
Name="flowDoc">
<!--set it's "paragraph template" here and
just bind all of the FlowDocument text to a
property in my ViewModel-->
</FlowDocument>
<RichTextBox>
The first "extra information" would be the number of the paragraph. The same way code editors specify the line number, I want the user to be able to see the paragraph number.
The second "extra information" would be a set of stats about the paragraph. Be it, world count, estimated reading time, etc etc etc.
--
At first, my plan was to create a flowdocument, set it's paragraph template to a grid with a textblock for the paragraph number, another one for the stats, and so on. But from what I've gather, this is not possible.
(Coming from ListViews, ListBoxes etc, I'm used to be able to set a template to the children of this controls. Almost as using an ForEach loop.)
I'm looking for a way to accomplish what's in the linked picture, the best idea I have is to, somehow, access the paragraphs positions and some other control generate the "extra information".
- Is this possible? If so, any suggestion?
- Is there a better way?
Thank you. Any idea would be greatly appreciated.