Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxAIChat.Initialized Event

Fires after the component is initialized.

Namespace: DevExpress.AIIntegration.Blazor.Chat

Assembly: DevExpress.AIIntegration.Blazor.Chat.v24.2.dll

NuGet Package: DevExpress.AIIntegration.Blazor.Chat

#Declaration

C#
[Parameter]
public EventCallback<IAIChat> Initialized { get; set; }

#Parameters

Type Description
IAIChat

An object that allows you to set up a chat assistant and manage chat history.

#Remarks

Handle the Initialized event to perform custom actions after initializing the component. For instance, you can call a SetupAssistantAsync method overload to set up an OpenAI Assistant or call the LoadMessages(IEnumerable<BlazorChatMessage>) method to load messages to the chat history.

razor
<div class="chat-demo-container">
    <DxAIChat CssClass="demo-chat" 
              Initialized="ChatInitialized" 
              ResponseContentFormat="ResponseContentFormat.Markdown">
        <MessageContentTemplate>
            <div class="demo-chat-content">
                @(new MarkupString(Markdig.Markdown.ToHtml(context.Content)))
            </div>
        </MessageContentTemplate>
    </DxAIChat>
</div>

@code {
    void ChatInitialized(IAIChat chat) {
        chat.LoadMessages(new[] {
            new BlazorChatMessage(Microsoft.Extensions.AI.ChatRole.User, "Hello, AI!"),
            new BlazorChatMessage(Microsoft.Extensions.AI.ChatRole.Assistant, "Hey there, human! What's on your mind? 😊")
        });
    }
}

Run Demo: AI Chat - Rich Formatted Response

View Example: AI Chat for Blazor - How to add DxAIChat component in Blazor, MAUI, WPF, and WinForms applications

See Also