Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:15:21+00:00 2026-06-14T20:15:21+00:00

I think i’m missing something obvious… I’m using the Telerik Rad controls for WPF

  • 0

I think i’m missing something obvious…
I’m using the Telerik Rad controls for WPF but i assume that the Rich text box uses some similar implementation for the mail merge functionality.

I want to have some friendly names on my mail merge fields. (namely spaces in the field names)
So i have a class for instance

Public Class someclass
{
<DisplayName("This is the complex description of the field")>
Public property thisfieldnamehasacomplexdescription as string

Public property anothercomplexfield as string
}

This is the only way i know to get “Friendly” names in the dropdown that is the mail merge.
So the two fields turn up okay as :
“This is the complex description of the field”
“anothercomplexfield”

but only anothercomplexfield actually populates with data when you do the merge.

Am i going to have to template the raddropdownbutton that holds the mail merge fields?
Is there an example of this somewhere?

Also a sub question. How do i add a scroll bar on these things?

(also i know this board is not a TELERIK specific board (duh!) but this might be useful to someone in the future. So i’ll copy the answer i get from Telerik into here!
http://www.telerik.com/community/forums/wpf/richtextbox/558428-radrichtextbox-mailmerge—using-displayname-to-create-a-friendly-name-with-spaces.aspx )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:15:22+00:00Added an answer on June 14, 2026 at 8:15 pm

    This is what telerik gave me:

    With the default MergeFields, it is not possible to change the display name fragment of the field in order to achieve a more friendly look. This should be possible if you implement a custom MergeField by deriving from the MergeField class. Here is a sample implementation that shows how this can be done:

    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 GetDisplayNameFragment()
    {
        return base.CreateFragmentFromText(string.Format(Field.DisplayNameFragmentFormat, this.GetFriendlyFieldName(this.PropertyPath)));
    }
    
    private string GetFriendlyFieldName(string fieldName)
    {
        int lettersInEnglishAlphabet = 26;
        List<char> separators = new List<char>(lettersInEnglishAlphabet);
        for (int i = 0; i < lettersInEnglishAlphabet; i++)
        {
            separators.Add((char)('A' + i));
        }
        StringBuilder newFieldName = new StringBuilder();
        int previousIndex = 0;
        for (int i = 1; i < fieldName.Length; i++)
        {
            if (separators.Contains(fieldName[i]))
            {
                if (previousIndex > 0)
                {
                    newFieldName.Append(" ");
                }
                newFieldName.Append(fieldName.Substring(previousIndex, i - previousIndex));
                previousIndex = i;
            }
        }
        newFieldName.Append(" " + fieldName.Substring(previousIndex));
        return newFieldName.ToString();
    }
    }
    

    Note that the fragment that is shown when the DisplayMode is Code cannot be changed.

    As for your other question, you can change the content of the dropdown button to show the friendly name of the fields and to include a scrollbar in the following way:
    1. First, remove the binding of the button to the InsertMergeFieldEmptyCommand from XAML and give it a name (e.g. insertMergeField).
    2. Next, add the following code in code-behind:

    AddMergeFieldsInDropDownContent(this.insertMergeFieldButton);
    
    private void AddMergeFieldsInDropDownContent(RadRibbonDropDownButton radRibbonDropDownButton)
    

    {
    Grid grid = new Grid();
    grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(100, GridUnitType.Pixel) });

    ScrollViewer scrollViewer = new ScrollViewer();
    scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
    StackPanel stackPanel = new StackPanel();
    
    foreach (string fieldName in this.editor.Document.MailMergeDataSource.GetColumnNames())
    {
        RadRibbonButton fieldButton = new RadRibbonButton()
        {
            Text = this.GetFriendlyFieldName(fieldName),
            Size = ButtonSize.Medium,
            HorizontalAlignment = HorizontalAlignment.Stretch,
            HorizontalContentAlignment = HorizontalAlignment.Left
        };
    
        fieldButton.Command = this.editor.Commands.InsertFieldCommand;
        fieldButton.CommandParameter = new MergeField() { PropertyPath = fieldName };
        //or
        //fieldButton.CommandParameter = new CustomMergeField() { PropertyPath = fieldName };
    
        stackPanel.Children.Add(fieldButton);
    }
    stackPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
    scrollViewer.Content = stackPanel;
    grid.Children.Add(scrollViewer);
    
    radRibbonDropDownButton.DropDownContent = grid;
    }
    

    You can, of course optimize the code of the GetFriendlyName method and add it in a way that will be available by both classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I have a basic understanding of this, but am hoping that someone
I think that asking this might be kind of silly but I'm still wondering
I think they are same thing but my boss say that is not right.
I think that my problem is minor but I can't find solution. I am
I think that handlers in android are tools to get different objects that are
I think I've figured out the problem. I'm using a IP webcam stream, doing
I think this could be a very easy question for you. But I have
Think that I have many activities,and all I want is this: I have a
I think I have a very popular problem, but not found answer for it
I think I might be using the wrong words, however I am looking for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.