User
Namespace: Wisej.Web.Ext.ChatControl
Assembly: Wisej.Web.Ext.ChatControl (4.1.0.0)
Represents a user in the context of a ChatBox.
- C#
- VB.NET
public class User
Public Class User
Users are compared by Id: two User instances with the same Id are considered equal. The ChatBox aligns messages from its own User to the right and messages from other users to the left.
Example:
chatBox.User = new User("1", "Alice");
var bot = new User("bot", "Assistant", "Images/bot.png")
{
BubbleColor = Color.LightGray
};
chatBox.DataSource.Add(new Message("Hi Alice!", null, bot));
Constructors
User()
Initializes a new instance of the User class.
Example:
var user = new User { Id = "42", Name = "Alice" };
chatBox.User = user;
User(id, name, imageSource)
Initializes a new instance of the User class with the specified ID, name, and image source.
| Name | Type | Description |
|---|---|---|
| id | String | The unique identifier of the user. |
| name | String | The name of the user. |
| imageSource | String | The image source of the user's avatar. When null, the default resource.wx/Wisej.Web.Ext.ChatControl/Images/person.svg image is used. |
Example:
var alice = new User("1", "Alice");
var bob = new User("2", "Bob", "Images/bob.png");
Properties
BubbleColor
Nullable<Color>: Returns or sets the color of the bubble to display for this user.
Value: The bubble background color, or null (default) to use the theme colors: @highlight for the User and @controlDark for other users.
Example:
var bot = new User("bot", "Assistant");
bot.BubbleColor = Color.LightSteelBlue;
Id
String: Returns or sets the unique identifier of the user.
Value: The user's identifier; the default is null.
The identifier is used for equality (Equals, ==, !=), to align messages and to select the default bubble color. Always assign a value: GetHashCode throws when it is null.
Example:
var user = new User();
user.Id = Guid.NewGuid().ToString();
ImageSource
String: Returns or sets the image source of the user's avatar.
Value: An image source (URL, resource or theme image); the default is resource.wx/Wisej.Web.Ext.ChatControl/Images/person.svg.
The avatar is displayed next to the user's messages when AvatarVisible is true.
Example:
var user = new User("1", "Alice");
user.ImageSource = "Images/alice.png";
Name
String: Returns or sets the name of the user.
Value: The display name shown above the user's messages; the default is null.
Example:
var user = new User("1", "Alice");
user.Name = "Alice Smith";