Skip to main content
You are viewing help content for pre-release software. This document and the features it describes are subject to change.
All docs
V26.2
  • Optimize Report Design Using AI in the WPF Report Designer

    • 5 minutes to read

    This help topic describes how to configure the End-User WPF Report Designer to allow AI-assisted report design optimization. The AI assistant can analyze report elements and their property values and suggest changes that clean up report structure and formatting.

    The AI Assistant does not change report content, data bindings, or layout. The assistant displays all proposed changes for review and updates the report only after you select the changes to apply.

    To fix report design issues with AI, refer to the following help topic: Fix Report Design Issues with AI in the WPF Report Designer.

    Install NuGet Packages

    This article uses Azure OpenAI. To see NuGet packages required for other supported AI services, refer to AI-powered Extensions.

    Register Your AI Client

    Note

    DevExpress AI-powered Extensions follow the “bring your own key” principle. DevExpress does not offer a REST API and does not ship built-in LLMs/SLMs. You need an active Azure/Open AI subscription to obtain the REST API endpoint, key, and model deployment name. Specify these variables at application startup to register AI clients and enable DevExpress AI-powered Extensions in your application.

    using DevExpress.AIIntegration;
    using DevExpress.Xpf.Core;
    using Azure.AI.OpenAI;
    using Microsoft.Extensions.AI;
    using System.ClientModel;
    using System.Windows;
    
    namespace DXReportsAIOptimization {
        public partial class App : Application {
            static App() {
                var container = AIExtensionsContainerDesktop.Default;
    
                IChatClient chatClient = new AzureOpenAIClient(AzureOpenAIEndpoint, AzureOpenAIKey)
                    .GetChatClient(ModelId).AsIChatClient();
    
                container.RegisterChatClient(chatClient);
            }
    
            private static Uri AzureOpenAIEndpoint = new Uri("YOUR_AZURE_OPENAI_END_POINT");
            private static ApiKeyCredential AzureOpenAIKey = new ApiKeyCredential("YOUR_OPENAI_API_KEY");
            static string ModelId = "YOUR_MODEL_NAME"; // For example, "gpt-5.4".
        }
    }
    

    Create and Configure an AI Assistant Behavior

    Attach the ReportDesignOptimizerBehavior to the End-User WPF Report Designer in XAML or code-behind.

    Markup:

    xmlns:dxrud="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesigner" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai" 
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"  
    ... 
    <dxrud:ReportDesigner x:Name="designer">
        <dxmvvm:Interaction.Behaviors>
            <dxai:ReportDesignOptimizerBehavior/>
        </dxmvvm:Interaction.Behaviors>
    </dxrud:ReportDesigner>
    

    Code-Behind:

    using DevExpress.AIIntegration.Wpf.Reporting;
    using DevExpress.Mvvm.UI.Interactivity;
    // ...
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
            ReportDesignOptimizerBehavior reportBehavior = new ReportDesignOptimizerBehavior();
            Interaction.GetBehaviors(designer).Add(reportBehavior);
        }
    }
    

    Available Optimizations

    The AI Assistant can optimize a report in the following ways:

    Convert adjacent controls to tables
    Converts three or more labels located in the same band into a single table. If label vertical positions (Y coordinates) differ, the AI Assistant aligns the labels before the conversion. Tables maintain a consistent report layout and improve XLS/XLSX/CSV export quality, compared to loosely positioned labels.
    Use type-based text alignment in table columns
    Corrects text alignment in labels and table cells bound to data fields. The AI Assistant determines alignment based on the field’s data type and name. For example, the assistant aligns numeric values to the right. Elements that already have correct alignment remain unchanged.
    Clean up report control formatting
    Finds two or more controls with identical appearance settings, creates a single report style from these settings, and assigns the style to the controls. Controls with distinct appearance settings remain unchanged. This optimization reduces report definition size and makes the report easier to maintain.

    Optimize a Report

    Click the report’s smart tag and expand the AI Assistant section. Use one of the following commands:

    Optimize with AI
    Runs all available optimizations.
    Convert adjacent controls to tables, Use type-based text alignment in table columns, Clean up report control formatting
    Runs the corresponding optimization only.

    AI Assistant section in smart tag

    While the LLM analyzes the report, the AI Assistant displays a wait screen. You can click Cancel to stop the analysis.

    When the analysis is complete, the Review Changes dialog appears. The AI Assistant does not modify the report until you select changes in this dialog.

    Review Changes dialog

    The dialog groups changes by optimization type. Group names match the AI Assistant commands in the smart tag. Each change lists the affected report element, the change description, relevant property values (old and new), and a label that indicates the change type (Modify, Add, or Remove). Use check boxes to select all or individual changes.

    Some changes depend on each other, and the AI Assistant applies them together:

    • A label-to-table conversion is a single change that removes the labels and adds the table. You cannot apply only a part of this change.
    • If a data alignment correction relies on a style that another change creates, the alignment change requires the style change. When you clear the style change, the dialog automatically clears the dependent alignment change. This behavior prevents a control from referencing a style that does not exist.

    Use Search to filter changes by text.

    Click Apply to update the report with the selected changes. Click Cancel to close the dialog without applying any changes.