AI-powered Extensions for WPF
- 5 minutes to read
Supported AI Clients
- OpenAI
- Azure OpenAI
- Semantic Kernel
- Ollama (self-hosted models)
Prerequisites
- .NET 8 SDK / .NET Framework v4.7.2
- OpenAI
- An active Open AI subscription
- OpenAI API key
- Microsoft.Extensions.AI.OpenAI
- Azure OpenAI
- An active Azure subscription.
- Azure Open AI Service resource
- Azure OpenAI .NET SDK
- Microsoft.Extensions.AI.OpenAI
- Semantic Kernel
- Microsoft.SemanticKernel
- An active account/subscription to the AI service of your choice
- Microsoft.SemanticKernel.Connectors.* NuGet package (a connector to the AI service of your choice)
- Ollama (self-hosted models)
Install DevExpress NuGet Packages
DevExpress.AIIntegration.Wpf
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-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.
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:
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.
Applies to:
Read the following help topic for additional information: Smart Autocomplete.