Skip to main content
All docs
V24.2

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

[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.

<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