I have resigned to a tardy solution for now, but if any of you finds a clean one, please post it.
I have used a Replace call of Stringbuilder to remove the undesired characters.
private string GetXaml(FlowDocument document)
{
if (document == null) return String.Empty;
else
{
StringBuilder sb = new StringBuilder();
using (XmlWriter xw = XmlWriter.Create(sb))
{
XamlDesignerSerializationManager sm = new XamlDesignerSerializationManager(xw);
sm.XamlWriterMode = XamlWriterMode.Expression;
XamlWriter.Save(document, sm);
}
sb.Replace("{}", "");
return sb.ToString();
}
}
I have a feeling that when the xamlwriter encounters "{" character - it intreprets that as a binding expression. I wonder what the escape sequence is for this character.
Note - I tried changing the
XamlWriterMode from XamlWriterMode.Expression to XamlWriterMode.Value
with no joy.
Krishna
2010-04-13 09:50:00