Hi, I am successfully able to display the custom merge field(inserts a table into the document) into my RadDocument. The problem I come across is that when I try to save or mail merge I am presented with an error
at Telerik.Windows.Documents.Layout.LayoutBox.InvalidateMeasure()at Telerik.Windows.Documents.Layout.LayoutBox.InvalidateMeasureUpToTheRoot()at Telerik.Windows.Documents.Layout.LayoutBox.OnAssociateDocumentElementChangedCore()at Telerik.Windows.Documents.Layout.LayoutBox.set_AssociatedDocumentElement(DocumentElement value)Am I doing anything wrong while creating a MergeField? Is the xamlserializer causing the error?
public class CustomMergeField : MergeField{ private const string CustomFieldName = "CustomField"; static CustomMergeField() { CodeBasedFieldFactory.RegisterFieldType(CustomMergeField.CustomFieldName, () => { return new CustomMergeField(); }); } public override string FieldTypeName { get { return CustomMergeField.CustomFieldName; } } public override Field CreateInstance() { return new CustomMergeField(); } protected override DocumentFragment GetResultFragment() { UniversalDTO universalDTO = this.Document.MailMergeDataSource.CurrentItem as UniversalDTO; if (universalDTO == null) { return null; } if (this.PropertyPath == "Collaterals") { Table table = new Table(); foreach (var coillateral in universalDTO.Collaterals) { Span span = new Span(coillateral.Type.Value); span.FontSize = 11.5; Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(span); Span span2 = new Span(coillateral.Description); span2.FontSize = 11.5; Paragraph paragraph2 = new Paragraph(); paragraph2.Inlines.Add(span2); TableCell cell = new TableCell(); cell.Blocks.Add(paragraph); cell.Borders = new TableCellBorders(new Border(1, BorderStyle.Single, Colors.Transparent)); TableCell cell2 = new TableCell(); cell2.Blocks.Add(paragraph2); cell2.Borders = new TableCellBorders(new Border(1, BorderStyle.Single, Colors.Transparent)); TableRow row = new TableRow(); row.Cells.Add(cell); row.Cells.Add(cell2); table.AddRow(row); } Section section = new Section(); section.Blocks.Add(table); RadDocument document = new RadDocument(); document.Sections.Add(section); document.MeasureAndArrangeInDefaultSize(); return new DocumentFragment(document); } return null; }}