Wpf – save a FlowDocument to BAML in a programmatic way

flowdocumentvisual-studio-2008wpf

Has anyone found a way to save a FlowDocument as BAML or other compressed format? I can import XML with images to create a new FlowDocument:

<TextRange class instance>.Load(fs, DataFormats.Rtf)

However, I haven't found a good way to save it in a 'native' compressed format. Uncompressed XAML is easy to generate using:

<TextRange class instance>.Save(fs, DataFormats.Xaml);

But is there any programmatic method to save it to a compressed format?

If there isn't an existing method, does anyone know where to find a programmatic XAML compiler? Or even just the BAML specifications? I could programmatically generate an entire XAML window with the FlowDocument embedded, but I'd still want to convert the XAML to BAML for faster load times. I'm using relatively large rtf documents and conversion time using DataFormats.Rtf is significant.

Best Answer

I do not think it is possible... The BamlWriter is marked as internal, this will hopefully open up soon!

I unfortunatly do not know of any XAML compilers

Related Topic