Class ChatMessage
Represents a message in the SfChatUI component.
Inheritance
Namespace: Syncfusion.Blazor.InteractiveChat
Assembly: Syncfusion.Blazor.dll
Syntax
public class ChatMessage : Object
Remarks
This class is used to define messages displayed in the Chat UI component, including properties for message content, timestamp, sender, and status.
Constructors
ChatMessage()
Declaration
public ChatMessage()
Properties
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 |
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 |
---|---|
System.String | A System.String representing the unique identifier. The default value is System.String.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 |
---|---|
System.Boolean | A System.Boolean 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 |
---|---|
System.Boolean | A System.Boolean 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
};
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 |
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 |
---|---|
System.String | A System.String representing the message content. The default value is System.String.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 Nullable<DateTime> Timestamp { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | A System.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 |
---|---|
System.String | A System.String representing the timestamp format. The default value is System.String.Empty. |
Remarks
This property defines the display format for the message timestamp, allowing customization per locale or user preference.