TX Text Control .NET for WPF

Mail Merge

Topic

When many documents share one layout and differ only in their data, such as invoices, letters or reports, mail merge produces them from a template and a data source. Three tutorials walk through one invoice in a WPF ribbon window: the template is designed with the Reporting tab of the ribbon, JSON data fills its merge fields, and a merge block turns the invoice items into table rows.

Choose a Tutorial

TutorialYou learn toMain members
Create a TemplateAdd the Reporting tab in XAML, give it sample data, insert merge fields and save the templateRibbonReportingTab, DataSourceManager.LoadJson, MergeField
Merge Data into FieldsMerge JSON data into the template in the background, show the result, save it as PDF and find fields without dataMailMerge, MergeJsonData, FieldMerged
Add Repeating Merge BlocksRepeat a table row for each item, with the ribbon or in code, and merge business objectsInsertMergeBlock, InsertMergeBlockDialog, MergeObject

The tutorials share the data invoice.json and the template invoice.docx, so work through them in the order of the table.

The Reporting tab of the WPF ribbon with the groups Data Source, Merge Fields, Merge Blocks and View.

Before You Start

What Is Specific to WPF

MailMerge, DataSourceManager and the merge field classes are the same as in the other TX Text Control products. In a WPF window, the differences are in the user interface:

  • The Reporting tab is a RibbonReportingTab in the Ribbon of WPF. It is declared in XAML and connected by name in the RibbonReportingTab attribute of the TextControl.
  • The field navigator is a Sidebar that the tab's FieldNavigatorSidebar attribute names. Without it, the tab hides its Field Navigation button.
  • The dialog boxes for merge blocks and data relations are classes of the namespace TXTextControl.DocumentServer.WPF, such as InsertMergeBlockDialog, which your code can open as well.

After These Tutorials