Skip to main content
All docs
V24.2

AI-powered Extensions for WPF

  • 5 minutes to read

Supported AI Clients

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

Prerequisites

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:

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 asChatClient = new OpenAI.OpenAIClient(OpenAIKey)
            .AsChatClient(Model);
            AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient);
        }
    }
}

Register Azure OpenAI Client

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

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 asChatClient = new AzureOpenAIClient(new Uri(AzureOpenAIEndpoint),
            new System.ClientModel.ApiKeyCredential(AzureOpenAIKey))
            .AsChatClient(ModelId);
            AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient);
        }
    }
}

Register Semantic Kernel

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

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);
        }
    }
}

Register Ollama Client

The following code snippet registers an Ollama client:

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 OllamaChatClient(new Uri("http://localhost:11434/"), "MODEL_NAME");
            AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient);
        }
    }
}

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.

AI Assistant - WPF Text Editor, DevExpress

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.

Read 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.

Explain Formula - WPF Spreadsheet, DevExpress

Run Demo: Explain Formula

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

Generate Image Description - WPF Rich Text Editor, DevExpress

Run Demo: Generate Image Description

Read 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.

Smart Autocomplete - WPF Text Editor, DevExpress

Run Demo: Smart Autocomplete

Applies to:

Text Editor

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