RTB - Mail Merge Functionality Disabled

4 posts, 0 answers
  1. Kevin Grossnicklaus
    Kevin Grossnicklaus avatar
    1 posts
    Member since:
    Sep 2009

    Posted 10 Oct 2011 Link to this post

    I'm attempting to utilize the Telerik Silverlight RadRichTextBox (2011 Q2 Pre SP1) for Mail Merge functionality.  I've been through all the examples and documents and have verified I have set the Editor.Document.MailMergeDataSource.ItemsSource property to a collection of objects (and I've verified this property remains set).   Thus far I am using the standard RadRichTextBoxRibbonUI ribbon and am hoping for functionality very similar to the online demo on Telerik's site.  Unfortunately, I cannot get any of the Mail Merge commands to enable regardless of what I do (they remain visible but disabled).  I ultimately am using the RTB in an MVVM environment with both a XamlDataprovider and an HtmlDataProvider (realizing that Mail Merge tokens won't persist in HTML).   I've tried commenting out one or both of the providers to see if they had any effect on why Mail Merge isn't being enabled.   Is there anything I need to do to get the Mail Merge functionality to become available?  Anyone else have issues getting the commands to become available?

  2. Boby
    Boby avatar
    586 posts

    Posted 11 Oct 2011 Link to this post

    Hello Kevin Grossnicklaus,
    Mail merge commands checks in their CanExecute method if mail merge data source is null (RadRichTextBox.Document.MailMergeDataSource == null). You could check the following  points:
    • the buttons are bound to the commands of the correct RadRichTextBox
    • mail merge data source of the current document is not null. When format providers imports a document, its MailMergeDataSource is not set by default.
    • RadRichTextBox is not read-only (RadRichTextBox.IsReadOnly)
    You could also try to manually set buttons' commands in the code-behind to check if the binding is failing. If this doesn't help, could you please send us a sample project (through a support ticket) that reproduces the problem, so we can investigate it further?
    Best wishes,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft R3 2016 release webinar banner
  4. Steven
    Steven avatar
    18 posts
    Member since:
    Sep 2012

    Posted 20 Mar 2014 in reply to Boby Link to this post


    I am experiencing a similar issue. I have a view with the RadRichTextBox and a DocxFormatProvider with a Docx property. The Docx property of the provider is set in a binding to a view model. When the screen is loaded, the system loads the byte[] content from a database and passes it to the view via the binding to the Docx property. This all works fine. Following an example on here, I then set the ItemsSource of the document's mail merge property and can confirm that the list is populated with our list of available fields. However, the MailMerge ribbon is never active - always greyed out. Is it possible it is checking it's Can* properties before the ItemsSource is ever set? Once the ItemsSource for the mail merge is set, is there a way to tell it to requery the Can* guard methods to enable the buttons? All the examples (if they even include a format provider) have the content coming from a xaml file already in the project and set via the codebehind. Is there an MVVM way such as what we're doing to get the content from the ViewModel via binding? The Mail Merge buttons simply don't get enabled despite having an ItemsSource.

  5. Petya
    Petya avatar
    973 posts

    Posted 25 Mar 2014 Link to this post

    Hello Steve,

    Thank you for contacting us.

    Indeed, mail merge in data-bound scenarios is a bit tricky. This comes from the fact that the binding updates the document so if you specify your item source in the constructor of the page, it will be cleared once the document is RadRichTextBox is changed.

    In order to make sure the item source is set, you can subscribe to the SetupDocument event of the respective data provider:
    void xamlDataProvider_SetupDocument(object sender, Telerik.Windows.Documents.FormatProviders.SetupDocumentEventArgs e)
        e.Document.MailMergeDataSource.ItemsSource = this.context.Employees;

    In general, you might want to subscribe to the DocumentChanged event of RadRichTextBox and set the item source there as well, as this will ensure that when a new document is created with the NewDocumentCommand or loaded with the OpenDocumentCommand, the respective source will be set.

    I hope this helps. Let us know if you have other questions or comments.


    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

Back to Top