alexa
menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class ChatMessage

    Represents a message in a chat conversation with enhanced attachment support.

    Inheritance
    object
    ChatMessage
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Syncfusion.Blazor.InteractiveChat
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ChatMessage
    Remarks

    This class extends the standard ChatMessage functionality to include file attachments.

    Use this model when you need to display messages with attached files in chat conversations.

    The enhanced model supports various file types and provides metadata for proper rendering.

    Examples
    // Create a chat message with text and attachments
    var message = new ChatMessage
    {
        Id = "msg1",
        Text = "Here are the files you requested",
        Type = MessageType.Text,
        Time = DateTime.Now,
        AttachedFile = new FileInfo
        {
            Name = "document.pdf",
            Size = 1548576,
            Url = "/uploads/document.pdf"
        }
    };

    Constructors

    ChatMessage()

    Declaration
    public ChatMessage()

    Properties

    AttachedFile

    Gets or sets the collection of file attachments associated with the message.

    Declaration
    public FileInfo AttachedFile { get; set; }
    Property Value
    Type Description
    FileInfo

    A List<T> of FileInfo objects representing the attached files. The default value is an empty collection.

    Remarks

    This property allows you to include one or more file attachments within a chat message.

    The collection can be modified at runtime to add or remove attachments.

    Each FileInfo object contains metadata about the attachment such as file name, size, and URL.

    Examples
    var message = new ChatMessage
    {
        Text = "Please review these files",
        AttachedFile = new FileInfo
        {
            Name = "presentation.pptx",
            Size = 2097152,
            Url = "/files/presentation.pptx"
        }
    };

    Author

    Gets or sets the user who sent the chat message in the SfChatUI component.

    Declaration
    public UserModel Author { get; set; }
    Property Value
    Type Description
    UserModel

    A UserModel representing the sender. The default value is null.

    Remarks

    This property identifies the user who authored the message, allowing messages to be associated with specific participants.

    ID

    Gets or sets the unique identifier for the chat message in the SfChatUI component.

    Declaration
    public string ID { get; set; }
    Property Value
    Type Description
    string

    A string representing the unique identifier. The default value is Empty.

    Remarks

    This property ensures each message in the SfChatUI component can be uniquely identified.

    IsForwarded

    Gets or sets whether the message has been forwarded.

    Declaration
    public bool IsForwarded { get; set; }
    Property Value
    Type Description
    bool

    A bool indicating the forwarded status of the message. The default value is false.

    Remarks

    When set to true, the message is visually marked as forwarded to indicate it originated from another context or conversation.

    Forwarded messages typically display additional visual indicators to help users understand the message's origin and context.

    Examples

    Creating a forwarded message:

    var forwardedMessage = new ChatMessageModel
    {
        Text = "Check out this important update",
        IsForwarded = true
    };

    IsPinned

    Gets or sets whether the message is pinned.

    Declaration
    public bool IsPinned { get; set; }
    Property Value
    Type Description
    bool

    A bool indicating the pinned status of the message. The default value is false.

    Remarks

    When set to true, the message will be visually highlighted and may appear in a dedicated pinned messages section for easier access and emphasis.

    Pinned messages are typically used to highlight important information or frequently referenced content within the chat conversation.

    Examples

    Creating a pinned message:

    var pinnedMessage = new ChatMessageModel
    {
        Text = "Important announcement",
        IsPinned = true
    };

    MentionUsers

    Gets or sets the array of users mentioned in the message.

    Declaration
    public List<UserModel> MentionUsers { get; set; }
    Property Value
    Type Description
    List<UserModel>

    An array of UserModel objects representing users referenced via the @mention feature. The default value is an empty array.

    Remarks

    This property contains the list of users referenced via the @mention feature in the message text.

    It is populated when mentions are selected from the suggestion popup during message composition.

    The property is optional and defaults to an empty array if no mentions are included in the message.

    RepliedTo

    Gets or sets the reference to the original message when this message is a reply.

    Declaration
    public MessageReplyModel RepliedTo { get; set; }
    Property Value
    Type Description
    MessageReplyModel

    A MessageReplyModel representing the replied message metadata. The default value is null.

    Remarks

    This property holds metadata of the original message being replied to, including author information, content, and timestamp details.

    When not null, the chat interface will render contextual information showing the relationship between the current message and the original message being replied to.

    Examples

    Creating a reply message:

    var replyMessage = new ChatMessageModel
    {
        Text = "Thanks for the information!",
        RepliedTo = new MessageReplyModel
        {
            MessageID = "msg-123",
            Text = "Here's the project update",
            User = originalSender,
            Timestamp = DateTime.Now.AddMinutes(-5)
        }
    };

    Status

    Gets or sets the status of the chat message in the SfChatUI component.

    Declaration
    public MessageStatusModel Status { get; set; }
    Property Value
    Type Description
    MessageStatusModel

    A MessageStatusModel representing the current message status (e.g., sent, delivered, read). The default value is null.

    Remarks

    This property indicates the message's status, enhancing communication clarity by showing whether a message has been sent, delivered, or read.

    Text

    Gets or sets the content of the chat message in the SfChatUI component.

    Declaration
    public string Text { get; set; }
    Property Value
    Type Description
    string

    A string representing the message content. The default value is Empty.

    Remarks

    This property contains the main text of the chat message displayed to users.

    Timestamp

    Gets or sets the date and time for the message in the SfChatUI component.

    Declaration
    public DateTime? Timestamp { get; set; }
    Property Value
    Type Description
    DateTime?

    A DateTime representing the timestamp of the message.

    Remarks

    This property provides temporal context for each message, aiding in chronological organization within the chat.

    TimestampFormat

    Gets or sets the format for displaying the timestamp in chat messages.

    Declaration
    public string TimestampFormat { get; set; }
    Property Value
    Type Description
    string

    A string representing the timestamp format. The default value is Empty.

    Remarks

    This property defines the display format for the message timestamp, allowing customization per locale or user preference.

    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved