xtrareports-405605-ai-powered-functionality-desktop-reporting-ai-powered-report-localization-wpf-report-designer.md
Follow instructions in this help topic to integrate AI-powered Report Localization into the WPF Report Designer. AI-powered Report Localization allows you to translate report elements directly within the End-User Report Designer.
Note
You can also localize a previously added language using AI. In this case, existing translated strings are replaced with AI-translated strings.
.NET8+ or .NET Framework v4.7.2+
DevExpress.AIIntegration.Wpf.ReportingThis help topic uses Azure OpenAI. See the following help topic for information about NuGet packages required for other supported AI services: AI-powered Extensions.
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".
}
}
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
Attach the ReportLocalizationBehavior to the Report Designer to enable AI-powered Localization:
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxrud="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesigner"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
<dxrud:ReportDesigner x:Name="reportDesigner">
<dxmvvm:Interaction.Behaviors>
<dxai:ReportLocalizationBehavior/>
</dxmvvm:Interaction.Behaviors>
</dxrud:ReportDesigner>
The following code snippet attaches the ReportLocalizationBehavior to the Report Designer in code behind:
using DevExpress.Xpf.Core;
using DevExpress.Mvvm.UI.Interactivity;
using DevExpress.AIIntegration.Wpf.Reporting;
namespace DXReportsAILocalization {
public partial class MainWindow : ThemedWindow {
public MainWindow() {
InitializeComponent();
ReportLocalizationBehavior reportLocalizationBehavior = new ReportLocalizationBehavior();
Interaction.GetBehaviors(reportDesigner).Add(reportLocalizationBehavior);
reportDesigner.OpenDocument(new Report1());
}
}
}
Imports DevExpress.Xpf.Core
Imports DevExpress.Mvvm.UI.Interactivity
Imports DevExpress.AIIntegration.Wpf.Reporting
Namespace DXReportsAILocalization
Public Partial Class MainWindow
Inherits ThemedWindow
Public Sub New()
InitializeComponent()
Dim reportLocalizationBehavior As New ReportLocalizationBehavior()
Interaction.GetBehaviors(reportDesigner).Add(reportLocalizationBehavior)
reportDesigner.OpenDocument(New Report1())
End Sub
End Class
End Namespace
See Also
AI-powered Report Localization in WinForms Report Designer