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
V25.2
  • Prompt to Report Behavior in the WPF Report Designer (CTP)

    • 8 minutes to read

    This help topic describes how to integrate the AI-powered Prompt-to-Report functionality into the Report Designer. Once integrated, users can create reports with prompts (report description in natural language).

    Important

    The Prompt-to-Report functionality is currently available as a community technology preview (CTP).

    Activate an AI Assistant

    Prerequisites

    .NET 8+ or .NET Framework v4.7.2+

    Install NuGet Packages

    This help topic uses Azure OpenAI. See the following help topic for information about NuGet packages required for other supported AI services: AI-powered Extensions.

    Register an AI Client

    The following code snippet registers an Azure OpenAI client at application startup:

    using DevExpress.AIIntegration;
    using DevExpress.Xpf.Core;
    using Azure.AI.OpenAI;
    using Microsoft.Extensions.AI;
    using System;
    using System.ClientModel;
    using System.Windows;
    
    namespace DXReportsAILocalization {
        public partial class App : Application {
            static App() {
                CompatibilitySettings.UseLightweightThemes = true;
                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-4.1".
        }
    }
    

    Create and Configure an AI Assistant Behavior

    Attach the ReportPromptToReportBehavior to the Report Designer to enable AI-powered Prompt-to-Report functionality.

    The following properties are available:

    ReportPromptToReportBehavior.FixLayoutErrors
    Specifies whether to automatically resolve overlapping report controls.
    ReportPromptToReportBehavior.PredefinedPrompts
    Specifies predefined prompts that can be used to create a report in the Report Wizard.
    ReportPromptToReportBehavior.RetryAttemptCount
    Specifies the number of attempts to fix report layout errors that may appear in the LLM response.
    ReportDesignerBehaviorBase.Temperature
    Gets or sets the balance between creativity and consistency in AI responses. Higher values increase variation.
    ReportDesignerBehaviorBase.PromptAugmentation
    Specifies additional instructions that modify the prompt before processing.

    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:ReportPromptToReportBehavior/>
        </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();
            ReportPromptToReportBehavior reportBehavior = new ReportPromptToReportBehavior();
            Interaction.GetBehaviors(designer).Add(reportBehavior);
        }
    }
    

    Create Reports

    Once the behavior is registered, the Report Wizard interface displays the new AI Prompt-to-Report option. Select this option to create an AI-generated report.

    ai-wpf-choose-report-type-page

    Select a data source option:

    ai-wpf-choose-data-source-option-page

    • No Data Source

      Creates a complete report structure based only on the user’s natural language description.

    • Add Data Source

      Allows users to create a report data source in the first step, displays the data source structure in the Report Wizard interface, and automatically includes this metadata in the LLM prompt. Users can reference available data source fields when they describe data-bound report elements.

    No Data Source Option

    If you select No Data Source, the “Enter Report Description” page appears. The Report Wizard interface includes a prompt input area with placeholder fields that help users specify a prompt.

    wpf-no-data-enter-report-description

    Edit the prompt as your needs dictate and click Finish to see the result:

    You can review the report layout and bind elements to data as needed.

    Note

    You can either adjust predefined prompts or write a new prompt from scratch. Review the Configure Report Prompt section for more information.

    Add Data Source Option

    If you select Add Data Source, the Wizard proceeds to the Select a Data Connection page.

    Once you specified a data source, the “Enter Report Description” page appears. The Report Wizard interface includes a prompt input area with placeholder fields that help users specify a prompt. The “Data Source Structure” section displays the data source schema. Add field names to the prompt to create a data-bound report.

    Modify the prompt as your needs dictate and press Finish to see the result:

    Note

    You can either adjust predefined prompts or write a new prompt from scratch. Review the Configure Report Prompt section for more information.

    Configure Report Prompt

    General Tips

    The output quality depends on the details you specify in the natural language description. Users should include detailed information about layout preferences, calculations, grouping requirements, and visualization types. Like any other LLM implementation, this system has limitations and may require manual adjustments to meet your specifications.

    You can specify Temperature to control the output randomness and use RetryAttemptCount to increase the number of attempts to fix report layout errors that may appear in the LLM response.

    Configure Predefined Prompts

    Built-in prompt suggestions show useful examples. You can review these examples to create your own prompts. For instance, check the “Prompt Template” entry - a basic template you can customize. You can set up page layout, styles, fields, and functions. Other templates cover common report types, such as invoices.

    wpf-no-data-enter-report-description

    Note that prompt changes made in the Report Wizard do not persist.

    To make permanent changes to built-in prompts, access the PredefinedPrompts collection. Modify prompt “Text” and “Title”. You can also add custom prompts to the collection.

    The following code snippet changes the title of “Prompt Template” to “My Changed Prompt”:

    Code-Behind:

    using DevExpress.AIIntegration.Wpf.Reporting;
    using DevExpress.Mvvm.UI.Interactivity;
    
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
            ReportPromptToReportBehavior reportBehavior = new ReportPromptToReportBehavior();
            var collection = AIReportPromptCollection.GetDefaultReportPrompts();
            collection[0].Title = "My Changed Prompt";
            reportBehavior.PredefinedPrompts = collection;
            Interaction.GetBehaviors(designer).Add(reportBehavior);
        }
    }
    

    The following image displays the result:

    wpf-ai-changed-predefined-prompt

    Add a New Prompt

    The following code snippet obtains built-in DevExpress prompts from AIReportPromptCollection, creates a custom prompt (an AIReportPrompt object), and adds this prompt to the collection. The collection is assigned to the ReportPromptToReportBehavior.PredefinedPrompts property.

    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" 
    xmlns:reporting="clr-namespace:DevExpress.AIIntegration.Reporting;assembly=DevExpress.AIIntegration.Reporting.Common.v25.2" 
    ... 
    <dxrud:ReportDesigner x:Name="designer">
        <dxmvvm:Interaction.Behaviors>
            <dxai:ReportPromptToReportBehavior FixLayoutErrors="true">
            <dxai:ReportPromptToReportBehavior.PredefinedPrompts>
                <reporting:AIReportPrompt Title="Custom Prompt" Text="{x:Static local:Prompts.CustomAIReportPrompt}" />
            </dxai:ReportPromptToReportBehavior.PredefinedPrompts>
            </dxai:ReportPromptToReportBehavior>
        </dxmvvm:Interaction.Behaviors>
    </dxrud:ReportDesigner>
    

    Code-Behind:

    using DevExpress.AIIntegration.Wpf.Reporting;
    using DevExpress.Mvvm.UI.Interactivity;
    using DevExpress.AIIntegration.Reporting;
    
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
            ReportPromptToReportBehavior reportBehavior = new ReportPromptToReportBehavior();
            reportBehavior.FixLayoutErrors = true;
            // Obtain built-in DevExpress prompts from the collection.
            var collection = AIReportPromptCollection.GetDefaultReportPrompts();
            // Create a custom prompt.
            AIReportPrompt customPrompt = new AIReportPrompt();
            customPrompt.Title = "Custom Prompt";
            customPrompt.Text = Prompts.CustomAIReportPrompt;
            // Add this prompt to the collection.
            collection.Add(customPrompt);
            // Display Prompts in the Report Wizard.
            reportBehavior.PredefinedPrompts = collection;
            Interaction.GetBehaviors(designer).Add(reportBehavior);
        }
        public static class Prompts {
            public const string CustomAIReportPrompt = "Create Sample Report:\r\n \r\nPage Setup:\r\n- Paper Size: A4\r\n- Report Margins:\r\n - Top & Bottom: 40\r\n - Left & Right: 60\r\n\r\nReport Header:\r\n- Title: Sample Report\r\n- Alignment: Center\r\n- Font: Comic Sans MS, 12pt, Bold\r\n\r\nCreate a horizontal table with the four column headers that correspond to fields in the bound data source.\r\n\r\nFont for column headers: Comic Sans MS, 12pt, Bold\r\n \r\nDetail Section:\r\nBind data cells to the fields corresponding to the column headers defined in the Group Header\r\nFont for data cells: Comic Sans MS, 12pt, Bold\r\n \r\nSummary Section:\r\nInclude calculated values for bound fields.\r\nSummary type: [Sum]\r\nFont for summary values: Comic Sans MS, 12pt, Bold";
        // ...
        }
    }
    

    After you add a custom prompt to the collection, it appears in the Report Wizard: