syncfusion-maui-chat

$npx mdskill add syncfusion/maui-ui-components-skills/syncfusion-maui-chat

Build chat interfaces with Syncfusion .NET MAUI Chat control.

  • Solves creating conversational UI for chatbots, support, or messaging.
  • Depends on Syncfusion.Maui.Chat NuGet package and .NET MAUI framework.
  • Recommends message types, events, and UI based on data binding and user actions.
  • Delivers rendered chat bubbles, typing indicators, and swipe actions to the app.

SKILL.md

.github/skills/syncfusion-maui-chatView on GitHub ↗
---
name: syncfusion-maui-chat
description: Implements Syncfusion .NET MAUI Chat (SfChat) control in .NET MAUI applications. Use when working with chat interfaces, messaging UI, conversational interfaces, chat bubbles, or message threads. Covers message types (text, image, calendar, card), data binding, events, suggestions, typing indicators, time breaks, and swiping actions.
metadata:
  author: "Syncfusion Inc"
  version: "34.1.29"
---

# Syncfusion .NET MAUI Chat (SfChat)

The Syncfusion .NET MAUI Chat control (`SfChat`) delivers a contemporary conversational UI for building chatbot interfaces, customer support screens, and multi-user messaging experiences. It supports rich message types, real-time typing indicators, suggestions, load-more history, swiping, and deep styling customization.

## When to Use This Skill

- Building a chat UI, chatbot interface, or messaging screen in .NET MAUI
- Displaying conversations between two or more users
- Sending/receiving text, images, cards, hyperlinks, or date/time picker messages
- Implementing typing indicators, message suggestions, or load-more history
- Customizing message appearance, shapes, delivery states, or themes
- Adding swipe actions, time-break grouping, or attachment buttons
- Localizing the chat UI or enabling accessibility features

## Documentation and Navigation Guide

### Getting Started
📄 **Read:** [references/getting-started.md](references/getting-started.md)
- NuGet installation (`Syncfusion.Maui.Chat`)
- Handler registration in `MauiProgram.cs`
- Basic `SfChat` initialization in XAML and C#
- ViewModel setup with `Messages` and `CurrentUser`
- Binding messages to the chat control
- Running the application

### Messages
📄 **Read:** [references/messages.md](references/messages.md)
- `TextMessage`, `DatePickerMessage`, `TimePickerMessage`, `CalendarMessage`
- `HyperlinkMessage`, `ImageMessage`, `CardMessage`
- Delivery states (`ShowDeliveryState`, `DeliveryState` enum, custom icons)
- Pin message (`AllowPinning`, `PinnedMessages`, events, template)
- Message template and `ChatMessageTemplateSelector`
- Customizable incoming/outgoing views
- Message spacing, shape, timestamp format, avatar/author visibility
- Sending messages, keyboard, multiline input, hide input view

### Data Binding
📄 **Read:** [references/data-binding.md](references/data-binding.md)
- Binding `ObservableCollection<object>` to `Messages`
- `CurrentUser` differentiation of sender/receiver
- Custom data models with `IMessage` / `ITextMessage`
- `ItemsSourceConverter` for external model binding
- Dynamically updating messages at runtime

### Suggestions
📄 **Read:** [references/suggestions.md](references/suggestions.md)
- Chat-level suggestions (`SfChat.Suggestions`)
- Message-level suggestions (`TextMessage.Suggestions`)
- `SuggestionItemSelected` event and command
- Customizing suggestion item templates

### Typing Indicator
📄 **Read:** [references/typing-indicator.md](references/typing-indicator.md)
- Enabling the typing indicator (`ShowTypingIndicator`)
- Setting author and message on `TypingIndicator`
- Customizing appearance
- Showing/hiding dynamically

### Load More
📄 **Read:** [references/load-more.md](references/load-more.md)
- Enabling load more (`LoadMoreBehavior`)
- `LoadMore` event and `LoadMoreCommand`
- Loading older messages on scroll
- `IsLazyLoading` property
- Disabling after all messages are loaded

### Events & Commands
📄 **Read:** [references/events.md](references/events.md)
- `SendMessage` / `SendMessageCommand`
- `ImageTapped` / `ImageTappedCommand`
- `CardTapped` / `CardCommand`
- `SuggestionItemSelected`
- `MessagePinned` / `MessageUnpinned`
- `LoadMore` / `LoadMoreCommand`
- Handling and cancelling event args

### Styles & Appearance
📄 **Read:** [references/styles.md](references/styles.md)
- Incoming and outgoing message styling
- Message input view styling
- Time-break and typing indicator styling
- Suggestion view styling
- `MessageShape` options
- Theme support (Material 3, Fluent)

### Accessibility & Localization
📄 **Read:** [references/accessibility-localization.md](references/accessibility-localization.md)
- WCAG 2.0 compliance
- Keyboard navigation and screen reader support
- `AutomationId` for UI testing
- Localization with `.resx` resource files
- Supported localizable strings
- RTL layout support

### Scrolling
📄 **Read:** [references/scrolling.md](references/scrolling.md)
- Programmatic scroll to a specific message (`ScrollToMessage`)
- Auto-scroll to bottom on new message (`CanAutoScrollToBottom`)
- Scroll to bottom floating button (`ShowScrollToBottomButton`)
- Customizing the scroll to bottom button (`ScrollToBottomButtonTemplate`)
- `Scrolled` event and `ChatScrolledEventArgs` (`IsBottomReached`, `IsTopReached`, `ScrollOffset`)

### Advanced Features
📄 **Read:** [references/advanced-features.md](references/advanced-features.md)
- Message swiping (left/right, `SwipeStarted`, `SwipeEnded`, swipe templates)
- Time-break grouping (custom time-break template)
- Attachment button (adding, customizing, `AttachmentButtonView`)
- Liquid glass effect (enabling, platform support, customization)
- `MessageSpacing` configuration
- Hiding the message input view (`ShowMessageInputView`)

---

## Quick Start

**1. Install the NuGet package:**
```bash
dotnet add package Syncfusion.Maui.Chat
```

**2. Register the handler in `MauiProgram.cs`:**
```csharp
using Syncfusion.Maui.Core.Hosting;

builder.ConfigureSyncfusionCore();
```

**3. Add `SfChat` in XAML:**
```xml
<ContentPage xmlns:sfChat="clr-namespace:Syncfusion.Maui.Chat;assembly=Syncfusion.Maui.Chat"
             xmlns:local="clr-namespace:MyApp">
    <ContentPage.BindingContext>
        <local:ChatViewModel/>
    </ContentPage.BindingContext>
    <sfChat:SfChat Messages="{Binding Messages}"
                   CurrentUser="{Binding CurrentUser}" />
</ContentPage>
```

**4. Define the ViewModel:**
```csharp
using Syncfusion.Maui.Chat;

public class ChatViewModel : INotifyPropertyChanged
{
    public ObservableCollection<object> Messages { get; set; }
    public Author CurrentUser { get; set; }

    public ChatViewModel()
    {
        CurrentUser = new Author { Name = "Nancy" };
        Messages = new ObservableCollection<object>
        {
            new TextMessage
            {
                Author = CurrentUser,
                Text = "Hello! How can I help you today?"
            },
            new TextMessage
            {
                Author = new Author { Name = "Bot", Avatar = "bot.png" },
                Text = "Hi Nancy! I am here to assist you."
            }
        };
    }

    public event PropertyChangedEventHandler PropertyChanged;
}
```

---

## Common Patterns

### Sending a message and responding
```csharp
// In ViewModel
public ICommand SendMessageCommand => new Command<object>(OnSendMessage);

private void OnSendMessage(object args)
{
    var e = args as SendMessageEventArgs;
    
    // ⚠️ IMPORTANT: By default, SfChat automatically adds the user's message to the 
    // Messages collection. Do NOT manually add it unless you set e.Handled = true
    
    // Add bot response after user sends message
    MainThread.BeginInvokeOnMainThread(async () =>
    {
        await Task.Delay(500); // Simulate processing
        Messages.Add(new TextMessage
        {
            Author = new Author { Name = "Bot", Avatar = "bot.png" },
            Text = $"You said: {e.Message.Text}"
        });
    });
}
```

**If you need full control over message addition, set `Handled = true`:**
```csharp
private void OnSendMessage(object args)
{
    var e = args as SendMessageEventArgs;
    e.Handled = true; // Prevent SfChat from auto-adding the message
    
    // Now you must manually add the message
    if (e.Message is TextMessage textMessage)
    {
        Messages.Add(textMessage); // You add it
        
        // Then handle response...
    }
}
```

### Adding quick reply suggestions
```csharp
Messages.Add(new TextMessage
{
    Author = new Author { Name = "Bot" },
    Text = "How would you like to proceed?",
    Suggestions = new ObservableCollection<ISuggestion>
    {
        new Suggestion { Text = "Option A" },
        new Suggestion { Text = "Option B" }
    }
});
```

### Showing a typing indicator
```csharp
sfChat.ShowTypingIndicator = true;
sfChat.TypingIndicator = new TypingIndicator
{
    Authors = new ObservableCollection<Author>
    {
        new Author { Name = "Bot", Avatar = "bot.png" }
    },
    Text = "Bot is typing..."
};
```

---

## Key Properties

| Property | Type | Purpose |
|---|---|---|
| `Messages` | `ObservableCollection<object>` | Collection of all messages |
| `CurrentUser` | `Author` | Identifies the local user (outgoing messages) |
| `ShowTypingIndicator` | `bool` | Toggle typing indicator |
| `TypingIndicator` | `TypingIndicator` | Set who is typing |
| `ShowDeliveryState` | `bool` | Show sent/delivered/read/failed icons |
| `AllowPinning` | `bool` | Enable message pinning |
| `MessageShape` | `MessageShape` | Message bubble shape |
| `MessageSpacing` | `double` | Vertical gap between messages |
| `ShowMessageInputView` | `bool` | Show/hide the message editor |
| `LoadMoreBehavior` | `LoadMoreOption` | Enable load-more on scroll |
| `AllowMultilineInput` | `bool` | Allow multi-line message entry |
| `ShowKeyboardAlways` | `bool` | Keep keyboard open after send |

More from syncfusion/maui-ui-components-skills

SkillDescription
syncfusion-maui-accordionImplements Syncfusion .NET MAUI Accordion (SfAccordion) - a vertically collapsible panel with stacked headers for expanding/collapsing content. Use when working with accordions, collapsible panels, expandable lists, employee lists with details, or FAQ sections in .NET MAUI applications. Covers AccordionItem configuration, expand modes, and grouped content display.
syncfusion-maui-ai-assistviewImplements Syncfusion .NET MAUI AI AssistView (SfAIAssistView) for AI-powered interactive chat interfaces. Use when working with AI chat interfaces, AI AssistView, SfAIAssistView, conversational UI, or chat with AI responses. Covers integrating AI services, creating chat UIs, implementing conversation flows, managing AI requests/responses, and displaying AI suggestions.
syncfusion-maui-autocompleteImplements and configure Syncfusion .NET MAUI Autocomplete (SfAutocomplete) control for intelligent text input with suggestions. Use when implementing autocomplete, autosuggest, type-ahead search, smart search, or filtered dropdowns in .NET MAUI applications. Covers data binding, filtering modes, custom search logic, AI-powered search, multi-selection with tokens, and UI customization.
syncfusion-maui-avatar-viewImplements Syncfusion .NET MAUI Avatar View (SfAvatarView) for displaying user profile pictures, initials, or group avatars. Use when working with avatar views, profile pictures, user images, initials display, profile icons, or contact images. Ideal for implementing user profile displays, contact lists, chat interfaces, or social feeds.
syncfusion-maui-backdropImplements Syncfusion .NET MAUI Backdrop Page (SfBackdropPage) with back layer and front layer surfaces. Use when working with backdrop pages, SfBackdropPage, back layer, front layer, or reveal/conceal animations. Covers backdrop navigation patterns, header icons, corner shapes, reveal height, layer state events, and liquid glass effect.
syncfusion-maui-badge-viewImplements Syncfusion .NET MAUI Badge View (SfBadgeView) control. Use when adding badge notifications, status indicators, unread counts, or notification overlays to MAUI applications. Covers SfBadgeView setup, badge text customization, position adjustments, animations, predefined symbols, and accessibility features.
syncfusion-maui-barcode-generatorImplements Syncfusion .NET MAUI Barcode Generator (SfBarcodeGenerator) for generating machine-readable barcodes. Use when working with barcodes, barcode generation, QR codes, data matrix, EAN codes, UPC codes, Code128, or Code39. This skill covers both one-dimensional (linear) and two-dimensional (matrix) barcode symbologies with extensive customization options.
syncfusion-maui-busy-indicatorImplements Syncfusion .NET MAUI Busy Indicator (SfBusyIndicator) for showing loading states, data processing, and app activity indicators. Use when displaying loading indicators, busy animations, activity spinners, or processing feedback in .NET MAUI apps. Covers busy indicator setup, animations, and visual feedback during long-running operations.
syncfusion-maui-buttonImplements and customize Syncfusion .NET MAUI Button (SfButton) control. Use when working with MAUI buttons, SfButton implementation, button customization, or visual states. Covers button icons, background images, RTL support, Liquid Glass effects, custom button views, button styling, events, and checkable buttons.
syncfusion-maui-calendarImplements and customize Syncfusion .NET MAUI Calendar (SfCalendar) control. Use when implementing calendar functionality, date selection (single, multiple, range), or calendar views (month, year, decade, century). Covers date restrictions (min/max dates, EnablePastDates, SelectableDayPredicate), calendar customization, events (ViewChanged, SelectionChanged, Tapped), and header/footer customization.