The requested page is not available for the requested platform. You are viewing the content for Default platform.

Provide Custom Editors for Report Parameters

  • 2 min 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.Xpf.Printing.Parameters.Models;


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 ParameterModel;
            if(parameter == null)
                return null;
            if(parameter.MultiValue)
                return Templates["multiValueTemplate"];
            return base.SelectTemplate(item, container);
        }
    }
}
See Also