Back to Devexpress

AI Assistant Extensions

wpf-405224-ai-powered-extensions-ai-assistant.md

latest24.8 KB
Original Source

AI Assistant Extensions

  • Oct 21, 2025
  • 9 minutes to read

AI Assistant extensions allow you to enhance the way your users interact with and manage text content. These extensions leverage advanced natural language processing (NLP) technologies to offer automated, intelligent text manipulation capabilities directly within your WPF applications.

Run Demo: AI Assistant View Example: AI-powered Text Extensions

Applies To

Activate AI Assistant

1. Install DevExpress NuGet Packages

  1. DevExpress.AIIntegration.Wpf
  2. DevExpress.Wpf

Read the following help topics for information on how to obtain the DevExpress NuGet Feed and install DevExpress NuGet packages:

2. Register AI Client

See the following help topic for information on required NuGet packages and system requirements: Register an AI Client.

The following code snippet registers an Azure OpenAI client at application startup within the AIExtensionsContainerDesktop container:

csharp
using Azure.AI.OpenAI;
using DevExpress.AIIntegration;
using DevExpress.Xpf.Core;
using Microsoft.Extensions.AI;
using System;
using System.Windows;

namespace AIAssistantApp {
    public partial class App : Application {
        static App() {
            CompatibilitySettings.UseLightweightThemes = true;
        }

        protected override void OnStartup(StartupEventArgs e) {
            base.OnStartup(e);
            ApplicationThemeHelper.ApplicationThemeName = "Win11Light";

            // For example, ModelId = "gpt-4o-mini"
            IChatClient azureChatClient = new Azure.AI.OpenAI.AzureOpenAIClient(new Uri(AzureOpenAIEndpoint),
                new System.ClientModel.ApiKeyCredential(AzureOpenAIKey)).GetChatClient(ModelId).AsIChatClient();
            AIExtensionsContainerDesktop.Default.RegisterChatClient(azureChatClient);
        }
    }
}
vb
Imports Azure.AI.OpenAI
Imports DevExpress.AIIntegration
Imports DevExpress.Xpf.Core
Imports Microsoft.Extensions.AI
Imports System
Imports System.Windows

Namespace AIAssistantApp
    Partial Public Class App
        Inherits Application

        Shared Sub New()
            CompatibilitySettings.UseLightweightThemes = True
        End Sub

        Protected Overrides Sub OnStartup(ByVal e As StartupEventArgs)
            MyBase.OnStartup(e)
            ApplicationThemeHelper.ApplicationThemeName = "Win11Light"

            ' For example, ModelId = "gpt-4o-mini"
            Dim azureChatClient As IChatClient = New AzureOpenAIClient(New Uri(AzureOpenAIEndpoint), 
                New System.ClientModel.ApiKeyCredential(AzureOpenAIKey)).GetChatClient(ModelId).AsIChatClient()
            AIExtensionsContainerDesktop.Default.RegisterChatClient(azureChatClient)
        End Sub
    End Class
End Namespace

3. Create and Configure AI Assistant Behaviors

To enable AI-powered functionality in a DevExpress WPF control, add mvvm and ai namespaces to the Window and attach the required AI-powered behaviors to the control.

The following example activates Change Style, Proofread, and Translate AI-powered extensions in a TextEdit control:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:ChangeStyleBehavior x:Name="ChangeStyle"/>
                <dxai:ProofreadBehavior x:Name="Proofread"/>
                <dxai:TranslateBehavior x:Name="Translate">
                    <dxai:LanguageInfo Culture="de-DE"/>
                    <dxai:LanguageInfo Culture="es-ES"/>
                </dxai:TranslateBehavior>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

4. Define Shortcuts and Bind Commands

The following example defines a Ctrl+Space shortcut that executes the Shorten AI-powered extension. The example also defines a similar command for the button.

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:ShortenBehavior x:Name="Shorten"/>
            </dxmvvm:Interaction.Behaviors>
            <dxe:TextEdit.InputBindings>
                <KeyBinding Gesture="Ctrl+Space"
                            Command="{Binding ElementName=Shorten, Path=ShortenCommand}"/>
            </dxe:TextEdit.InputBindings>
        </dxe:TextEdit>
        <Button Content="Shorten Selected Text"
            Command="{Binding ElementName=Shorten, Path=ShortenCommand}"/>
    </Grid>
</dx:ThemedWindow>

Change Style

ChangeStyleBehavior rephrases or paraphrases the selected text while retaining its original meaning. This behavior allows you to generate alternative versions of the same content to match a specific genre or format. You can choose from 12 predefined styles (see WritingStyle).

The following example activates the AI-powered “Change Style” extension in a TextEdit control:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:ChangeStyleBehavior x:Name="ChangeStyle"/>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

Change Tone

ChangeToneBehavior adjusts the tone of the text to meet audience or context requirements. This option helps tailor the voice of your content.

Tone styles include:

  • Casual
  • Confident
  • Friendly
  • Professional
  • Straightforward

The following example activates the AI-powered “Change Tone” extension in a TextEdit control:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:ChangeToneBehavior x:Name="ChangeTone"/>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

Expand

ExpandBehavior enriches your text with additional information or in-depth explanations.

The following example activates the AI-powered “Expand” extension in a TextEdit control:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:ExpandBehavior x:Name="Expand"/>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

Explain

ExplainBehavior transforms text into more understandable terms that make complex content more accessible and understandable.

The following example activates the AI-powered “Explain” extension in a TextEdit control:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:ExplainBehavior x:Name="Explain"/>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

Proofread

ProofreadBehavior reviews the text for spelling, grammar, punctuation, and style errors.

The following example activates the AI-powered “Proofread” extension in a TextEdit control:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:ProofreadBehavior x:Name="Proofread"/>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

Shorten

ShortenBehavior removes unnecessary details and makes content more concise.

The following example activates the AI-powered “Shorten” extension in a TextEdit control:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:ShortenBehavior x:Name="Shorten"/>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

Summarize

SummarizeBehavior generates a brief summary of long text.

SummarizeBehavior supports the following summarization modes:

  1. Abstractive Summarization

  2. Extractive Summarization

The following example activates the AI-powered “Summarize” extension in a TextEdit control:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:SummarizeBehavior x:Name="Summarize" SummarizationMode = "Extractive"/>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

Translate

TranslateBehavior converts the text from one language to another while maintaining the original meaning and context. Use the Languages parameter to specify target languages/cultures for text translation.

The following example activates the AI-powered “Translate” extension in a TextEdit control:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:TranslateBehavior x:Name="Translate">
                    <dxai:LanguageInfo Culture="de-DE"/>
                    <dxai:LanguageInfo Culture="es-ES"/>
                </dxai:TranslateBehavior>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

Document Summarization

DocumentSummarizeBehavior generates a brief summary of long text contained in a document.

DocumentSummarizeBehavior supports the following summarization modes:

  • Abstractive Summarization

  • Extractive Summarization

The following example activates the AI-powered “Summarize” extension in a Document Preview control:

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:DocumentSummarizeBehavior SummarizationMode="Abstractive" /> 
    </dxmvvm:Interaction.Behaviors> 
</dxp:DocumentPreviewControl>

Review the following help topic for more information on how to use this functionality in the WPF Document Preview: Summarize and Translate Reports in the WPF Document Preview.

Document Translation

DocumentTranslateBehavior converts the text contained in a document from one language to another while maintaining the original meaning and context.

Use the Languages property to specify target languages for text translation.

The following example activates the AI-powered “Translate” extension in a Document Preview control:

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> 
    </dxmvvm:Interaction.Behaviors> 
</dxp:DocumentPreviewControl>

Review the following help topic for more information on how to use this functionality in the WPF Document Preview: Summarize and Translate Reports in the WPF Document Preview.

Inline Document Translation

DocumentTranslateInlineBehavior converts the text contained in a document from one language to another on the document preview. Unlike DocumentTranslateBehavior the Translate Inline command translates text directly on the document preview without additional dialogs. You can export or print the translated document.

The following example activates the AI-powered “Translate Inline” extension in a Document Preview control:

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:DocumentTranslateInlineBehavior>
            <dxai:LanguageInfo Culture="de-DE"/> 
        </dxai:DocumentTranslateInlineBehavior>
    </dxmvvm:Interaction.Behaviors> 
</dxp:DocumentPreviewControl>

Additionally, you can specify the following properties:

PromptAugmentationSpecifies additional instructions that modify the prompt before processing.TemperatureSpecifies the balance between creativity and consistency in AI responses.

Review the following help topic for more information on how to use this functionality in the WPF Document Preview: Translate Reports Inline in the WPF Document Preview.

Prompt Augmentation

DevExpress AI-powered extensions allow you to specify additional instructions that modify the default prompt before processing. Prompt augmentation improves the relevance and accuracy of the AI’s response. Use the PromptAugmentation property to specify additional instructions.

The following code snippet registers a ChangeStyleBehavior and assigns it to a TextEdit control. It uses the AI-powered extension to change style of the original text and obtain the result in English, regardless of the language used in the original text:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:ChangeStyleBehavior x:Name="ChangeStyle"
                                PromptAugmentation="Always translate the result into English."/>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

Ask AI Assistant (Custom Prompt)

CustomRequestBehavior displays the “Ask AI Assistant” item in the context menu. The “Ask AI Assistant” item invokes a dialog that allows users to interact with an AI-powered assistant directly within your application. A user can enter a question or prompt, and the AI assistant will process the query and generate an answer.

The user can insert the answer directly into a document or text field with a single click. The user can insert the answer above/below the cursor, replace all content or selected text, or copy the answer to the clipboard.

The following example activates the AI-powered “Ask” extension in a TextEdit control:

xaml
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" 
    xmlns:dxai="http://schemas.devexpress.com/winfx/2008/xaml/ai"
    x:Class="AIAssistant.MainWindow"
    Title="MainWindow" Height="800" Width="800">
    <Grid>
        <dxe:TextEdit TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top">
            <dxmvvm:Interaction.Behaviors>
                <dxai:CustomRequestBehavior x:Name="CustomRequest"/>
            </dxmvvm:Interaction.Behaviors>
        </dxe:TextEdit>
    </Grid>
</dx:ThemedWindow>

Chunking (Processing Long Input Text)

If input text is too long, the DevExpress control displays a dialog that informs a user that the input text must be divided into manageable chunks to ensure accurate processing.

To process chunks one by one, the user can click the “Proceed” button, or enable the “I consent to process all remaining chunks” option to process all chunks automatically.

After processing, chunks are reassembled into a single output.

Tip

Use the ChunkMaxLength property to specify how much text can be processed at once. The chunk length is limited to 6,000 symbols. The TextBufferMaxSize property specifies the maximum size of the input text, in bytes.

See Also

AI-powered Extensions for WPF