Alex Rivera | Logout

How do you erase all content of a flowdocument

Asked 2012-06-08T14:39:20.427
8

I have created a flowdocument and added numerous paragraphs to it programmically. Now in the I would like to be able to reset the flow document to a blank slate resulting in everything being erased.

I have looked for things like Clear, Reset, RemoveAll, Erase. Is there a method to emptying the document?

Edit
Report

1 Answer

22

Clear the Blocks collection of the FlowDocument:

document.Blocks.Clear();

The How to: Manipulate a FlowDocument through the Blocks Property includes this example, as well as other common operations (such as inserting a new paragraph at the beginning, or deleting the last block element).

answered 2012-06-08T14:46:46.120

Your Answer