ScottG
ScottG

Reputation: 11111

Are there any FlowDocument diff viewers for WPF?

We have 2 flowdocuments that we'd like to compare similar to when using a diff viewer (winmerge, beyond compare, etc). Has anybody done this or know how to get the text out of a flowdocument to do a compare?

Upvotes: 1

Views: 764

Answers (2)

henon
henon

Reputation: 2518

I just forged together a basic WPF diff viewer. Shouldn't be too hard to adapt it to write a side by side Flowdocument diff view.

Find more information here: http://www.eqqon.com/index.php/GitSharp#GitSharp.Demo

-- henon

Upvotes: 1

Fred
Fred

Reputation: 2733

Here's a way to save it as raw xaml (text file) from the code-behind file, assuming that the flowdocument (not viewer) itself is named "myFlowDoc", if only the viewer is named, use the property .Document of the viewer to get it. And a stream to a stream myStream (FileStream, MemoryStream, etc doesn't matter).

// Create a TextRange around the entire document.
TextRange documentTextRange = new TextRange(myFlowDoc.ContentStart, myFlowDoc.ContentEnd);

// Save it. Note that it will not respect current stream position;
//  it'll assume that it gets the entire stream.
documentTextRange.Save(myStream, DataFormats.Xaml);

Upvotes: 1

Related Questions