How do you delete the entire contents of a flowdocument

I created a flowdocument and added numerous paragraphs to it programmatically. Now I would like to be able to reset the stream document to an empty slider, as a result of which everything is erased.

I was looking for things like Clear, Reset, RemoveAll, Erase. Is there any way to empty the document?

+5
source share
2 answers

Clear collection Blocks FlowDocument:

document.Blocks.Clear();

The FlowDocument documentation includes this example, as well as other general operations (such as inserting a new paragraph at the beginning or deleting the last block element).

+12
source

The following example clears all contents ( Block) of FlowDocument.

flowDoc.Blocks.Clear();

. FlowDocument.

+8

All Articles