BaseChatItemElement
Base virtualized chat item that lays out a message bubble with optional avatar, author label, status, and reply bubbles.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.UI.dll
Syntax:
public class BaseChatItemElement : LightVisualElement, INotifyPropertyChanged, ICustomTypeDescriptor, ISupportSystemSkin, IBindableComponent, IComponent, IDisposable, ISupportDrag, ISupportDrop, IShortcutProvider, IStylableElement, IStylableNode, IPrimitiveElement, IShapedElement, IFillElement, IBorderElement, IBoxStyle, IBoxElement, IDrawFillElement, IImageElement, ITextPrimitive, ITextProvider, IVirtualizedElement<BaseChatDataItem>
Inheritance: objectDisposableObjectRadObjectRadElementVisualElementRadComponentElementRadItemUIItemBaseLightVisualElementBaseChatItemElement...
Derived Classes:
Implements:
Inherited Members
Constructors
public BaseChatItemElement()
Fields
Identifies the theme state used for a message authored by the current user.
public static RadProperty IsOwnMessageProperty
Properties
Gets the avatar child, or null when the avatar factory omits it.
public virtual ChatMessageAvatarElement AvatarPictureElement { get; }
Gets the data item currently represented by this element.
public virtual BaseChatDataItem Data { get; protected set; }
Implements:
Gets or sets whether the message belongs to the current user.
public bool IsOwnMessage { get; set; }
The value selects the
IsOwnMessagetheme state on this item and its bound children. Layout alignment is determined by the attached data item's IsOwnMessage value.
Gets the visual element used to display the message's primary content.
public LightVisualElement MainMessageElement { get; }
Gets the label that displays the message time and author.
public ChatMessageNameElement NameLabelElement { get; }
Gets whether an avatar is present and enabled by the owning chat view.
protected bool ShowAvatar { get; }
Gets whether the author label should be visible for the current message.
protected virtual bool ShowNameLabel { get; }
Edited messages always show the label; otherwise it is shown only for single or last messages in a group.
Gets whether the footer should display the data item's status text.
protected virtual bool ShowStatusLabel { get; }
Status text is shown only for single or last messages in a group; the footer remains visible for its actions.
Gets the footer element used for message status and actions.
public ChatMessageStatusElement StatusLabelElement { get; }
Methods
Attaches a data item, synchronizes the visual children, and subscribes to subsequent data changes.
public virtual void Attach(BaseChatDataItem data, object context)
The data item to display.
contextobjectThe virtualization context; this base implementation does not use it.
Implements:
Creates a circular, image-stretched avatar element with spacing around it.
protected virtual ChatMessageAvatarElement CreateAvatarElement()
The avatar element to include in the item, or null to omit the avatar.
Creates the avatar, author, status, and main-message children and binds the own-message theme state on the avatar, author, and status children.
protected override void CreateChildElements()
Overrides:
Creates the visual element that displays the message's primary content.
protected virtual LightVisualElement CreateMainMessageElement()
A chat-message bubble element.
Creates the label used for the message time, author name, and edited marker.
protected virtual ChatMessageNameElement CreateNameLabel()
The author-and-time label.
Creates a reply bubble element for a reply message. Override to customize.
protected virtual ChatReplyBubbleElement CreateReplyBubbleElement()
Creates the stack element that hosts the reply bubbles. Override to customize.
Creates the footer element used for message status and actions.
protected virtual ChatMessageStatusElement CreateStatusLabel()
The message status element.
Synchronizes the visual item after a data-item property changes, except for measured-size updates.
protected virtual void DataPropertyChanged(object sender, PropertyChangedEventArgs e)
The data item that raised the notification.
ePropertyChangedEventArgsThe changed property name.
Unsubscribes from the current data item and clears the item reference.
public virtual void Detach()
Implements:
Disposes managed resources.
protected override void DisposeManagedResources()
Overrides:
Formats the time and author for the name label, omitting the author name for own messages.
protected virtual string GetNameLabelText()
The short timestamp, optional author name, and localized edited marker.
Sets the base item's horizontal padding, bottom margin, and border-aware measurement behavior.
protected override void InitializeFields()
Overrides:
Indicates whether this base element can represent the specified data item.
public virtual bool IsCompatible(BaseChatDataItem data, object context)
The data item to check.
contextobjectThe virtualization context.
Returns:false; derived item elements provide their own compatibility checks.
Implements:
Measures the optional avatar and the name, message, and status rows, then combines their desired sizes.
Handles the mouse right-click to show the context menu.
Handles a click on a reply bubble. By default raises the ReplyBubbleClicked event on
the chat element and, when not handled, scrolls the chat view to the message being replied to.
protected virtual void OnReplyBubbleClicked(ChatMessage replyToMessage)
Excludes the avatar, name, message, and status children because this class arranges them explicitly.
protected override bool ShouldArrangeChild(RadElement child)
The child element to check.
Returns:false for the explicitly arranged children; otherwise the base result.
Overrides:
Excludes the avatar, name, message, and status children because this class measures them explicitly.
protected override bool ShouldMeasureChild(RadElement child)
The child element to check.
Returns:false for the explicitly measured children; otherwise the base result.
Overrides:
Shows the context menu for this message.
Copies the attached data item's avatar, name, status, and own-message state into the visual children and raises item formatting.
public virtual void Synchronize()
Implements:
Rebuilds the reply bubbles inside the supplied stack to match the current data's ReplyToMessages. Sets the stack's visibility based on the reply state. Subclasses are responsible for adding the stack into their visual tree.
protected virtual void SynchronizeReplyBubbles(StackLayoutElement replyBubblesStack)