DevExpress AI-powered Extensions for WinForms
- 6 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
Install the following DevExpress NuGet Packages:
DevExpress.AIIntegration.WinForms
DevExpress.AIIntegration.OpenAI
(required if you use the WinForms Chat control with OpenAI.Assistant)DevExpress.Win.Design
(enables design-time features for DevExpress UI controls)
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.
Register OpenAI Client
The following code snippet registers an OpenAI client:
using Microsoft.Extensions.AI;
using DevExpress.AIIntegration;
internal static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
IChatClient asChatClient = new OpenAI.OpenAIClient(OpenAIKey)
.AsChatClient("GPT4o");
AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient);
Application.Run(new Form1());
}
static string OpenAIKey { get { return Environment.GetEnvironmentVariable("OPENAI_API_KEY"); } }
}
Register Azure OpenAI Client
The following code snippet registers an Azure OpenAI client:
using Microsoft.Extensions.AI;
using DevExpress.AIIntegration;
internal static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
IChatClient asChatClient = new Azure.AI.OpenAI.AzureOpenAIClient(new Uri(AzureOpenAIEndpoint),
new System.ClientModel.ApiKeyCredential(AzureOpenAIKey))
.AsChatClient("GPT4o");
AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient);
Application.Run(new Form1());
}
static string AzureOpenAIEndpoint { get { return Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"); } }
static string AzureOpenAIKey { get { return Environment.GetEnvironmentVariable("AZURE_OPENAI_APIKEY"); } }
}
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;
internal static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
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);
Application.Run(new Form1());
}
}
Register Ollama Client
The following code snippet registers an Ollama client:
using Microsoft.Extensions.AI;
using DevExpress.AIIntegration;
internal static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
IChatClient asChatClient = new OllamaChatClient(new Uri("http://localhost:11434/"), "MODEL_NAME");
AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient);
Application.Run(new Form1());
}
}
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 provide automated, intelligent text manipulation capabilities directly within your Windows Forms 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:
Read the following help topic for additional information: AI-powered Text Transform Extensions (Behaviors).
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 WinForms Spreadsheet and Rich Text Edit controls.
Play the following animation to see how the AI-powered “Generate Image Description” extension in a WinForms 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.
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 Data Grid and LayoutControl-driven forms.
Play the following animation to see how “SmartPaste” works:
Applies to:
Read the following help topic for additional information: Smart Paste.
Smart Search
“Smart Search” works alongside the 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 misspellings.
Play the following animation to see how AI-powered smart search works in the DevExpress WinForms Ribbon control:
Applies to:
Read the following help topic for additional information: Smart Search.
AI Chat Control
Note
The AI Chat Control leverages BlazorWebView
to reuse the DevExpress Blazor AI Chat component (DxAIChat). To use the WinForms AI Chat Control you must have one of the following active subscriptions: Universal, DXperience, ASP.NET & Blazor.
The AI Chat Control (AIChatControl
) allows you to incorporate an interactive, Copilot-inspired chat-based UI within your WinForms application. The DevExpress AI Chat Control (AIChatControl
) can only be used in Windows Forms 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 Skins
Read the following help topic for additional information: AI Chat Control.