Back to Devexpress

AI-powered Extensions for WPF

wpf-405223-ai-powered-extensions.md

latest18.5 KB
Original Source

AI-powered Extensions for WPF

  • Nov 24, 2025
  • 8 minutes to read

Supported AI Clients

  • OpenAI
  • Azure OpenAI
  • Semantic Kernel
  • Ollama (self-hosted models)

Prerequisites

DevExpress.AIIntegration assemblies reference the following versions of Microsoft.Extensions.AI.* NuGet packages:

Package Namev25.2
Microsoft.Extensions.AI9.7.1
Microsoft.Extensions.AI.OpenAI9.7.1-preview.1.25365.4

See the following breaking change advisory for more information: DevExpress.AIIntegration references stable versions of Microsoft AI packages.

Install DevExpress NuGet Packages

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

Register AI Clients

DevExpress AI-powered extensions operate within an AIExtensionsContainerDesktop container. This container manages all registered AI clients so that DevExpress UI controls can automatically leverage AI services. You should register an AI client at application startup (App.xml.cs).

Register OpenAI Client

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

csharp
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 = "Office2019Colorful";

            // For example, Model = "gpt-4o-mini"
            IChatClient openAIChatClient = new OpenAI.OpenAIClient(OpenAIKey).GetChatClient(Model)
                .AsIChatClient();
            AIExtensionsContainerDesktop.Default.RegisterChatClient(openAIChatClient);
        }
    }
}
vb
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 = "Office2019Colorful"

            ' For example, Model = "gpt-4o-mini"
            Dim openAIChatClient As IChatClient = New OpenAI.OpenAIClient(OpenAIKey).GetChatClient(Model).AsIChatClient()
            AIExtensionsContainerDesktop.Default.RegisterChatClient(openAIChatClient)
        End Sub
    End Class
End Namespace

Register Azure OpenAI 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 = "Office2019Colorful";

            // 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

Imports System
Imports System.Windows
Imports Azure.AI.OpenAI

Namespace AIAssistantApp
    Partial Public Class App
        Inherits Application

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

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

            ' 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

Register Semantic Kernel

Install the connector package for the AI service. This example uses Microsoft.SemanticKernel.Connectors.Google.

csharp
using Microsoft.Extensions.AI;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.Google;
using DevExpress.AIIntegration;
using DevExpress.Xpf.Core;
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 = "Office2019Colorful";

            var builder = Kernel.CreateBuilder().AddGoogleAIGeminiChatCompletion("YOUR_MODEL_ID", "YOUR_API_KEY", GoogleAIVersion.V1_Beta);
            Kernel kernel = builder.Build();
            IChatClient googleChatClient = kernel.GetRequiredService<IChatCompletionService>().AsChatClient();
            AIExtensionsContainerDesktop.Default.RegisterChatClient(googleChatClient);
        }
    }
}
vb
Imports Microsoft.Extensions.AI
Imports Microsoft.SemanticKernel
Imports Microsoft.SemanticKernel.ChatCompletion
Imports Microsoft.SemanticKernel.Connectors.Google
Imports DevExpress.AIIntegration
Imports DevExpress.Xpf.Core
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 = "Office2019Colorful"

            Dim builder = Kernel.CreateBuilder().AddGoogleAIGeminiChatCompletion("YOUR_MODEL_ID", "YOUR_API_KEY", GoogleAIVersion.V1_Beta)
            Dim kernel As Kernel = builder.Build()
            Dim googleChatClient As IChatClient = kernel.GetRequiredService(Of IChatCompletionService)().AsChatClient()
            AIExtensionsContainerDesktop.Default.RegisterChatClient(googleChatClient)
        End Sub
    End Class
End Namespace

Register Ollama Client

The following code snippet registers an Ollama client:

csharp
using OllamaSharp;
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 = "Office2019Colorful";

            // Requires the 'Microsoft.Extensions.AI.Ollama' NuGet package.
            IChatClient asChatClient = new OllamaApiClient(new Uri("http://localhost:11434/"), "MODEL_NAME");
            AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient);
        }
    }
}
vb
Imports OllamaSharp
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 = "Office2019Colorful"

            ' Requires the 'Microsoft.Extensions.AI.Ollama' NuGet package.
            Dim asChatClient As IChatClient = New OllamaApiClient(New Uri("http://localhost:11434/"), "MODEL_NAME")
            AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient)
        End Sub
    End Class
End Namespace

AI-powered Extensions

AI Assistant (Text Transform)

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

Run Demo: AI Assistant

AI-powered options include:

  • Change Style*
  • Change Tone*
  • Expand*
  • Explain
  • Proofread
  • Shorten
  • Summarize
  • Translate
  • Ask AI Assistant (allows users to interact with an AI-powered assistant directly within your application)

Applies to:

Note

The WPF Spreadsheet control does not support Change Style, Change Tone, and Expand extensions.

See the following help topic for additional information on how to activate and use AI Assistant extensions: AI Assistant Extensions.

Explain Formula

The AI-powered “Explain Formula” extension generates a detailed explanation of the formula used in a worksheet cell in the DevExpress Spreadsheet control.

Run Demo: Explain Formula

See the following help topic for additional information: Explain Formula.

Generate Image Description

The AI-powered “Generate Image Description” extension generates the description for the image in DevExpress WPF Spreadsheet and Rich Text Edit controls.

Play the following animation to see how the AI-powered “Generate Image Description” extension in a WPF Rich Text Editor generates Alt text for an image:

Run Demo: Generate Image Description

See the following help topic for additional information: Generate Image Description.

Smart Autocomplete

The AI-powered “Smart Autocomplete” feature intelligently predicts and suggests words or phrases based on the user’s current input. As you type, the AI model analyzes the context of the text and makes relevant suggestions in real time.

Run Demo: Smart Autocomplete

Applies to:

Text Editor

See the following help topic for additional information: Smart Autocomplete.

Smart Paste

“SmartPaste” is an AI-powered feature that transforms the traditional copy-and-paste process into a smarter, more efficient tool. Designed to improve productivity, SmartPaste analyzes the content you copy and intelligently assigns the right values to the appropriate fields or row cells in the DevExpress WPF Data Grid, TreeList, and LayoutControl-driven forms.

Play the following animation to see how SmartPaste works:

Run Demo: Smart Paste - Data Grid

Applies to:

See the following help topic for additional information: Smart Paste.

Smart Search works alongside traditional search algorithms to offer a more powerful and user-friendly search experience. It offers results that are more aligned with what the user is seeking, even if the input contains spelling errors.

Run Demo: Smart Search - WPF Ribbon

Applies to:

See the following help topic for additional information: Smart Search.

Semantic search enables users to locate relevant data quickly and accurately within large datasets. Unlike standard keyword-based search, semantic search leverages Natural Language Processing (NLP) to analyze search queries beyond exact keyword matching.

Semantic search uses an embedding generator to convert text into numerical vector representations. Vectors are stored in a vector database. When a user enters a search query, the search engine computes similarity scores between the query vector and stored data vectors to return the most relevant results.

Run Demo: Semantic Search - Grid Control

Applies to: Data Grid

See the following help topic for additional information: Semantic Search.

Custom Extensions

You can create custom extensions based on DevExpress AI-powered extensions. See the following help topic for additional information and examples: Create Custom AI-powered Extensions.

Run Demo

AI Chat Control

Note

The DevExpress AI Chat Control (AIChatControl) can only be used in WPF applications that target the .NET 8+ framework.

The AI Chat Control (AIChatControl) allows you to incorporate an interactive, Copilot-inspired chat-based UI within your WPF application. The DevExpress AI Chat Control can only be used in WPF applications that target the .NET 8+ framework.

Features include:

  • Seamless Integration with AI Services
  • Markdown Message Rendering
  • Copy and Regenerate Responses
  • Manual Handling of Chat Messages
  • Create an Assistant That Chats Using Your Own Data
  • Save and Load Chat History
  • Streaming
  • DevExpress Light and Dark Themes

See the following help topic for additional information: AI Chat Control.

See Also