Skip to main content

Provide Custom Editors for Report Parameters

  • 2 minutes to read

This example demonstrates how you can provide custom editors for report parameters of arbitrary types. In particular, it shows how to utilize a custom ComboBoxEdit as an editor for a multi-value report parameter.

To provide the described functionality, implement a custom parameter template selector and assign it to the ParametersPanel.ParameterTemplateSelector property of the DocumentPreviewControl‘s ParametersPanel. In this example, the custom parameters template selector extends the base ParameterTemplateSelector class with the capability to provide a custom editor template for each parameter, whose Parameter.MultiValue property is set to true. The custom editor template is declared in XAML.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using DevExpress.Xpf.Printing.Parameters;
using DevExpress.XtraReports.Parameters.ViewModels;

namespace CustomParameterEditorsWPF {
    public class CustomParameterTemplateSelector : ParameterTemplateSelector {
        Dictionary<object, DataTemplate> templates = new Dictionary<object, DataTemplate>();
        public Dictionary<object, DataTemplate> Templates { get { return templates; } }

        public override DataTemplate SelectTemplate(object item, DependencyObject container) {
            var parameter = item as ParameterItemViewModel;
            if(parameter == null)
                return null;
                return Templates["multiValueTemplate"];
            return base.SelectTemplate(item, container);
See Also