When a document is imported (for example from XAML) and then exported to DOCX or RTF, the fields lose their formatting. The issue is not observed if the document is just created.Workaround: Change the fields display mode of all fields in headers/footers just before the export:
private void UpdateHeadersFooters(RadDocument document)
{
foreach (Section section in document.Sections)
{
if (section.Headers.Default.Body != null)
{
this.UpdateFields(section.Headers.Default.Body);
}
if (section.Headers.First.Body != null)
{
this.UpdateFields(section.Headers.First.Body);
}
if (section.Headers.Even.Body != null)
{
this.UpdateFields(section.Headers.Even.Body);
}
if (section.Footers.Default.Body != null)
{
this.UpdateFields(section.Footers.Default.Body);
}
if (section.Footers.First.Body != null)
{
this.UpdateFields(section.Footers.First.Body);
}
if (section.Footers.Even.Body != null)
{
this.UpdateFields(section.Footers.Even.Body);
}
}
}
private void UpdateFields(RadDocument radDocument)
{
RadDocumentEditor editor = new RadDocumentEditor(radDocument);
editor.ChangeAllFieldsDisplayMode(FieldDisplayMode.Code);
}