Back to Devexpress

Summarize and Translate Reports in the WPF Document Preview

xtrareports-405263-ai-powered-functionality-desktop-reporting-summarize-translate-in-wpf-document-preview.md

latest7.6 KB
Original Source

Summarize and Translate Reports in the WPF Document Preview

  • Nov 24, 2025
  • 4 minutes to read

Follow instructions in this article to integrate AI-powered Summarize and Translate commands into the DocumentPreviewControl.

SummarizeUses generative AI to summarize report content and displays core insights associated with this report.TranslateUses AI services to translate report content to another language.

Activate AI Assistant

Install NuGet Packages

Install the following NuGet packages:

The following tutorial uses Azure OpenAI. Refer to the requirements section for information about NuGet packages required for other supported AI services.

Register AI Client

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

csharp
using Azure.AI.OpenAI;
using DevExpress.AIIntegration;
using Microsoft.Extensions.AI;
using System.ClientModel;
// ...
public partial class App : Application {
    static string AzureOpenAIEndpoint { get { return "AZURE_OPENAI_ENDPOINT"; } }
    static string AzureOpenAIKey { get { return "AZURE_OPENAI_APIKEY"; } }
    static string DeploymentName { get { return "gpt-4o-mini"; } }

    public App() {
        IChatClient chatClient = new AzureOpenAIClient(
           new Uri(AzureOpenAIEndpoint),
           new ApiKeyCredential(AzureOpenAIKey))
               .GetChatClient(DeploymentName).AsIChatClient();
        AIExtensionsContainerDesktop.Default.RegisterChatClient(chatClient);
    }
}
vb
Imports Azure.AI.OpenAI
Imports DevExpress.AIIntegration
Imports Microsoft.Extensions.AI
Imports System.ClientModel
' ...
Partial Public Class App
    Inherits Application
    Private Shared ReadOnly Property AzureOpenAIEndpoint() As String
        Get
            Return "AZURE_OPENAI_ENDPOINT"
        End Get
    End Property
    Private Shared ReadOnly Property AzureOpenAIKey() As String
        Get
            Return "AZURE_OPENAI_APIKEY"
        End Get
    End Property
    Private Shared ReadOnly Property DeploymentName() As String
        Get
            Return "gpt-4o-mini"
        End Get
    End Property
    Public Sub New()
        Dim chatClient As IChatClient = (New AzureOpenAIClient(New Uri(AzureOpenAIEndpoint), New ApiKeyCredential(AzureOpenAIKey))).GetChatClient(DeploymentName).AsIChatClient()
        AIExtensionsContainerDesktop.Default.RegisterChatClient(chatClient)
    End Sub
End Class

Note

Review the following help topic for information on how to register other supported AI services: Register AI Clients.

Create and Configure AI Assistant Behaviors

Register DocumentSummarizeBehavior and DocumentTranslateBehavior, specify their setting, and assign them to the Document Preview control.

The following settings are available:

  • SummarizationMode (for Summarize behavior)

  • Languages (for Translate behavior)

  • Temperature

Markup:

xaml
xmlns:dxp="http://schemas.devexpress.com/winfx/2008/xaml/printing" 
xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai" 
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"  
... 
<dxp:DocumentPreviewControl Name="preview"> 
    <dxmvvm:Interaction.Behaviors> 
        <dxai:DocumentTranslateBehavior> 
            <dxai:LanguageInfo Culture="de-DE"/> 
            <dxai:LanguageInfo Culture="es-ES"/> 
            <dxai:LanguageInfo Culture="pt-BR"/> 
        </dxai:DocumentTranslateBehavior> 
        <dxai:DocumentSummarizeBehavior SummarizationMode="Abstractive" /> 
    </dxmvvm:Interaction.Behaviors> 
</dxp:DocumentPreviewControl>

Code-Behind:

csharp
using System.Collections.Generic;
using System.Globalization;
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Wpf;
using DevExpress.Mvvm.UI.Interactivity;
// ...
public partial class MainWindow : Window {
    public MainWindow() {
        InitializeComponent();
        AddAIBehaviors();
    }
    void AddAIBehaviors() {
        var translateBehavior = new DocumentTranslateBehavior() {
            Languages = new List<LanguageInfo>() {
                new LanguageInfo() { Culture = new CultureInfo("de-DE") },
                new LanguageInfo() { Culture = new CultureInfo("es-ES") },
                new LanguageInfo() { Culture = new CultureInfo("pt-BR") },
            }
        };
        var summarizeBehavior = new DocumentSummarizeBehavior() { 
            SummarizationMode = SummarizationMode.Abstractive
        };
        var behaviors = Interaction.GetBehaviors(preview);
        behaviors.Add(translateBehavior);
        behaviors.Add(summarizeBehavior);
    }
}
vb
Imports System.Collections.Generic
Imports System.Globalization
Imports DevExpress.AIIntegration
Imports DevExpress.AIIntegration.Wpf
Imports DevExpress.Mvvm.UI.Interactivity
' ...
Partial Public Class MainWindow
    Inherits Window

    Public Sub New()
        InitializeComponent()
        AddAIBehaviors()
    End Sub
    Private Sub AddAIBehaviors()
        Dim translateBehavior = New DocumentTranslateBehavior() With {
            .Languages = New List(Of LanguageInfo)() From {
                New LanguageInfo() With {.Culture = New CultureInfo("de-DE")},
                New LanguageInfo() With {.Culture = New CultureInfo("es-ES")},
                New LanguageInfo() With {.Culture = New CultureInfo("pt-BR")}
            }
        }
        Dim summarizeBehavior = New DocumentSummarizeBehavior() With {.SummarizationMode = SummarizationMode.Abstractive}
        Dim behaviors = Interaction.GetBehaviors(preview)
        behaviors.Add(translateBehavior)
        behaviors.Add(summarizeBehavior)
    End Sub
End Class

Use Translate Command

You can access the Translate command in the AI context menu of the Document Preview control.

Right-click an opened report or selected report content. Select Translate from the AI Assistant submenu.

A dialog appears. Specify the input text range (selected content, document page, or entire document) and target language. Click “Translate” to generate and display a translation.

Click the copy icon to copy operation output.

Use Summarize Command

You can access the Summarize command in the AI context menu of the Document Preview control.

Right-click an open report or selected report content. Select Summarize from the AI Assistant submenu.

A dialog appears. Specify the input text range for summarization (selected content, document page, or entire document). Click “Summarize” to display the summary.

Click the copy icon to copy operation output.