TL;DR: Skip complex filters, let users simply describe what they need. With our .NET MAUI DataGrid and Azure OpenAI, queries like “customers from New York” are instantly converted into accurate filters. The result is a faster, more intuitive, zero learning curve experience built on a clean, scalable architecture for modern cross-platform apps. Ready to see how this works in practice? Let’s dive in.
What if filtering thousands of rows in a grid felt as simple as typing a sentence?
Traditional filtering forces users into rigid patterns: dropdowns, exact field names, and predefined conditions. Most grids still expect users to think like developers, remember column names, pick operators, and navigate layered menus just to find what they need. It’s slow, unintuitive, and often frustrating.
Now imagine your users simply typing:
- Orders above $500,
- Show high-value customers, and
- Products under $100
…and instantly seeing exactly what they asked for.
No clicks. No confusion. Just results.
That’s the power of AI‑powered natural language filtering.
In this blog, we’ll show you how to bring this smart, natural-language filtering to life using Syncfusion® .NET MAUI DataGrid and Azure OpenAI, so your apps feel less like tools and more like intelligent assistants.
Why natural language filtering matters
Natural language filtering transforms rigid, technical filtering into a simple, conversational experience. It lets users interact with data the way they naturally think, not the way the UI demands.
Key benefits
- Faster data discovery. Skip menus and get instant results by simply describing what you need.
- Zero learning curve. No need to remember column names, operators, or filter syntax.
- Intuitive interaction. Users express intent in plain English, and AI handles the complexity behind the scenes.
- Greater confidence. Explore data freely without worrying about making mistakes.
How it works
AI-powered filtering bridges the gap between human language and structured data by:
- Understanding intent,
- Translating it into precise filter logic, and
- Delivering accurate results instantly.
The result: Faster insights, happier users, and a dramatically simpler, more engaging data experience.
Note: Before proceeding, refer to the getting started with .NET MAUI DataGrid documentation.
Prerequisites
- Visual Studio.
- Create a .NET MAUI application.
- An Azure OpenAI resource and a valid API key.
How to embed AI-powered natural-language filtering in .NET MAUI DataGrid?
Adding AI-powered filtering to the .NET MAUI DataGrid isn’t just about calling an API, it requires a clean and scalable architecture. By using the MVVM pattern, you can neatly separate UI, business logic, and data handling, while dependency injection ensures your AI services are consistently available across the app.
Step 1: Create the AI filtering service
At the core of this implementation is the AIFilterService. Its role is to convert user-friendly, natural-language queries into a structured format your DataGrid can understand and apply.
For example, a query like:
“Female employees with rating ≥ 8 and salary > 5000”
is transformed into a compact JSON-based filter plan.
Here’s what happens behind the scenes:
- A schema-aware prompt is sent to Azure OpenAI to ensure responses align with your data structure.
- The AI returns a cleaned JSON filter definition (removing code fences and noise).
- The response is then validated and parsed into strongly typed models such as FilterPlan or Condition, with support for nested filter groups.
If anything goes wrong, such as a missing configuration or invalid JSON, the service safely returns null, ensuring your app remains stable.
Refer to the following code example for implementation details.
C#
public class AIFilterService : IAIFilterService
{
// Converts a natural language prompt into a JSON filter plan via Azure OpenAI.
public async Task<FilterPlan?> CreateFilterPlanAsync(string naturalLanguagePrompt)
{
// Ensure Azure OpenAI settings are present
if (string.IsNullOrWhiteSpace(AzureBaseService.Endpoint) ||
string.IsNullOrWhiteSpace(AzureBaseService.DeploymentName) ||
string.IsNullOrWhiteSpace(AzureBaseService.Key))
{
return null;
}
// Clear instructions: JSON filter plans only, aligned with your grid schema
var system = "You convert plain English filters into strictly valid JSON filter plans for a data grid.";
var user = $"Grid schema:\n{SchemaText}\n\nUser query:\n{naturalLanguagePrompt}\n\nReturn JSON only.";
try
{
// Call Azure OpenAI and get raw content
var content = await CallAzureAsync(system, user);
// Extract compact JSON (removes json fences, trims noise)
var json = ExtractJsonObject(content);
if (string.IsNullOrWhiteSpace(json))
return null;
// Parse JSON into a FilterPlan (parsing implemented elsewhere)
return ParseFilterPlanFromJson(json);
}
catch
{
// Fail safe: return null on network/parse errors
return null;
}
}
}
Step 2: Configuring AI services
Once your AI filtering service is ready, the next step is to make it available throughout your app. This is done during app startup by registering your services using dependency injection.
By configuring your AI service and ViewModel at this stage, you ensure they can be easily accessed wherever needed without manual instantiation or tight coupling.
C#
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddAiServices(this IServiceCollection services)
{
services.AddSingleton<IAIFilterService, AIFilterService>();
services.AddSingleton<EmployeesViewModel>();
services.AddTransient<MainPage>();
return services;
}
}
Step 3: Integrating Azure OpenAI with your .NET MAUI app
To enable natural language filtering, your app needs to connect to Azure OpenAI, which powers the understanding and interpretation of user queries.
To do so:
- First, ensure you have access to Azure OpenAI and create a deployment in the Azure portal.
- If you do not have access, please refer to the create and deploy Azure OpenAI service guide to set up a new account.
- Note down the deployment name, endpoint URL, and API key.
- Make sure you’ve installed the Azure.AI.OpenAI NuGet package from the NuGet Gallery.
- In your base service class (
AzureBaseService), initialize theOpenAIClient. - Replace the
Endpoint,DeploymentName, andKeywith the actual values from your Azure OpenAI resource.
C#
public abstract class AzureBaseService
{
internal const string Endpoint = "YOUR_END_POINT";
internal const string DeploymentName = "DEPLOYMENT_NAME";
internal const string Key = "API_KEY";
protected AzureBaseService() {}
}
Next, we’ll define the models that make this integration work seamlessly.
Read the full blog post on the Syncfusion Website
Top comments (0)