Back to Devexpress

Prompt to Report Behavior in the WPF Report Designer (CTP)

xtrareports-405625-ai-powered-functionality-desktop-reporting-prompt-to-report-in-wpf-report-designer.md

latest16.7 KB
Original Source

Prompt to Report Behavior in the WPF Report Designer (CTP)

  • Nov 28, 2025
  • 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:

csharp
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".
    }
}
vb
Imports DevExpress.AIIntegration
Imports DevExpress.Xpf.Core
Imports Azure.AI.OpenAI
Imports Microsoft.Extensions.AI
Imports System
Imports System.ClientModel
Imports System.Windows

Namespace DXReportsAILocalization
    Public Partial Class App
        Inherits Application

        Shared Sub New()
            CompatibilitySettings.UseLightweightThemes = True
            Dim container = AIExtensionsContainerDesktop.Default

            Dim chatClient As IChatClient = New AzureOpenAIClient(AzureOpenAIEndpoint, AzureOpenAIKey) _
                .GetChatClient(ModelId).AsIChatClient()

            container.RegisterChatClient(chatClient)
        End Sub

        Private Shared AzureOpenAIEndpoint As New Uri("YOUR_AZURE_OPENAI_END_POINT")
        Private Shared AzureOpenAIKey As New ApiKeyCredential("YOUR_OPENAI_API_KEY")
        Private Shared ModelId As String = "YOUR_MODEL_NAME" ' For example, "gpt-4.1".
    End Class
End Namespace

Tip

How to Register OpenAI, Azure OpenAI, Ollama, and Semantic Kernel Clients

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.FixLayoutErrorsSpecifies whether to automatically resolve overlapping report controls.ReportPromptToReportBehavior.PredefinedPromptsSpecifies predefined prompts that can be used to create a report in the Report Wizard.ReportPromptToReportBehavior.RetryAttemptCountSpecifies the number of attempts to fix report layout errors that may appear in the LLM response.ReportDesignerBehaviorBase.TemperatureGets or sets the balance between creativity and consistency in AI responses. Higher values increase variation.ReportDesignerBehaviorBase.PromptAugmentationSpecifies additional instructions that modify the prompt before processing.

Markup:

xaml
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:

csharp
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);
    }
}
vb
Imports DevExpress.AIIntegration.Wpf.Reporting
Imports DevExpress.Mvvm.UI.Interactivity
' ...
Partial Public Class MainWindow
    Inherits Window

    Public Sub New()
        InitializeComponent()
        Dim reportBehavior As New ReportPromptToReportBehavior()
        Interaction.GetBehaviors(designer).Add(reportBehavior)
    End Sub
End Class

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.

Select a data source option:

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.

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.

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:

csharp
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);
    }
}
vb
Imports DevExpress.AIIntegration.Wpf.Reporting
Imports DevExpress.Mvvm.UI.Interactivity

Partial Public Class MainWindow
    Inherits Window

    Public Sub New()
        InitializeComponent()
        Dim reportBehavior As New ReportPromptToReportBehavior()
        Dim collection = AIReportPromptCollection.GetDefaultReportPrompts()
        collection(0).Title = "My Changed Prompt"
        reportBehavior.PredefinedPrompts = collection
        Interaction.GetBehaviors(designer).Add(reportBehavior)
    End Sub
End Class

The following image displays the result:

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:

xaml
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:

csharp
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";
    // ...
    }
}
vb
Imports DevExpress.AIIntegration.Wpf.Reporting
Imports DevExpress.Mvvm.UI.Interactivity
Imports DevExpress.AIIntegration.Reporting

Partial Public Class MainWindow
    Inherits Window

    Public Sub New()
        InitializeComponent()
        Dim reportBehavior As New ReportPromptToReportBehavior()
        reportBehavior.FixLayoutErrors = True
        ' Obtain built-in DevExpress prompts from the collection.
        Dim collection = AIReportPromptCollection.GetDefaultReportPrompts()
        ' Create a custom prompt.
        Dim customPrompt As 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)
    End Sub
    Public NotInheritable Class Prompts

        Private Sub New()
        End Sub

        Public Const CustomAIReportPrompt As String = "Create Sample Report:" & vbCrLf & " " & vbCrLf & "Page Setup:" & vbCrLf & "- Paper Size: A4" & vbCrLf & "- Report Margins:" & vbCrLf & " - Top & Bottom: 40" & vbCrLf & " - Left & Right: 60" & vbCrLf & vbCrLf & "Report Header:" & vbCrLf & "- Title: Sample Report" & vbCrLf & "- Alignment: Center" & vbCrLf & "- Font: Comic Sans MS, 12pt, Bold" & vbCrLf & vbCrLf & "Create a horizontal table with the four column headers that correspond to fields in the bound data source." & vbCrLf & vbCrLf & "Font for column headers: Comic Sans MS, 12pt, Bold" & vbCrLf & " " & vbCrLf & "Detail Section:" & vbCrLf & "Bind data cells to the fields corresponding to the column headers defined in the Group Header" & vbCrLf & "Font for data cells: Comic Sans MS, 12pt, Bold" & vbCrLf & " " & vbCrLf & "Summary Section:" & vbCrLf & "Include calculated values for bound fields." & vbCrLf & "Summary type: [Sum]" & vbCrLf & "Font for summary values: Comic Sans MS, 12pt, Bold"
    ' ...
    End Class
End Class

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