Skip to main content
All docs
V26.1
  • AIChatControl.MessageSending Event

    Fires when a user submits a message to the chat.

    Namespace: DevExpress.AIIntegration.Wpf.Chat

    Assembly: DevExpress.AIIntegration.Wpf.Chat.v26.1.dll

    NuGet Package: DevExpress.AIIntegration.Wpf.Chat

    Declaration

    public event EventHandler<AIChatControlMessageSendingEventArgs> MessageSending

    Event Data

    The MessageSending event's data class is DevExpress.AIIntegration.Blazor.Chat.WebView.AIChatControlMessageSendingEventArgs.

    Remarks

    To manually process messages sent to an AI service, handle the MessageSending event. For example, you can manually call the AI client or service of choice, and return its responses to the chat. The following example adds responses to user questions:

    <dxaichat:AIChatControl x:Name="aiChatControl"
                    MessageSending="AiChatControl_MessageSending"
                    HorizontalAlignment="Stretch" 
                    VerticalAlignment="Stretch" 
                    Margin="10">
    </dxaichat:AIChatControl>
    
    async void AiChatControl_MessageSending(object sender, AIChatControlMessageSendingEventArgs e) {
        e.Cancel = true; 
        await e.Chat.SendMessageAsync($"Processed: {e.Content}", ChatRole.User);
    }
    

    Note

    Set the e.Cancel event parameter to true to block automatic message delivery and use the AIChatControl.SendMessageAsync method to send the message to the AI service manually.

    Refer to the following help topic for additional information: AI Chat Control

    See Also