I have some data that I want to present in a FlowDocument
. This will basically be a view that explains the data in a friendly way, with section headers, paragraphs of text, etc., and which I will display in a FlowDocumentScrollViewer.
To this end, I would like to create a bulleted list (<List>
) out of the contents of an ObservableCollection
. I know how to do that with ItemsControl
, but how do I do it for ListItem
elements in a FlowDocument
, since they're part of the TextElement
class hierarchy rather than the Control
hierarchy? Is there an equivalent of ItemsControl
for text content inside a TextBlock
or FlowDocument
?
Edit: The article Sergey linked to is the perfect starting point. The only problem is that the article's code can only use a Section
or a TableRowGroup
as the items panel, and doesn't yet support using a <List>
. But that was trivial to fix -- just a matter of adding this code at the end of ItemsContent.GenerateContent
, just before the final else
:
else if (panel is List)
((List) panel).ListItems.Add((ListItem) element);