New to Telerik UI for WinUI? Download free 30-day trial

Getting Started with WinUI Chat

This topic will guide you through the process of creating a sample application containing RadChat.

Prerequisites

Before adding the Badge, you need to:

  1. Set up your WinUI project.

  2. Create your Telerik UI for WinUI application and install the Telerik UI for WinUI components depending on the required installation approach:

Add the Assembly References

To use the RadChat component, add a reference to the Telerik.WinUI.Controls.dll assembly.

Define the Component

To use the control, create a new RadChat instance.

Defining RadChat

<telerik:RadChat x:Name="chat"/> 
Empty RadChat

Empty RadChat

Adding Authors to RadChat

Two authors will be defined for the following example. Note, that the CurrentAuthor property of RadChat must be set.

Adding Authors to RadChat

public partial class MainWindow : Window 
{ 
    private Author currentAuthor; 
    private Author otherAuthor; 
 
    public MainWindow() 
    { 
        InitializeComponent(); 
 
        currentAuthor = new Author("Peter"); 
        otherAuthor = new Author("Steven"); 
        this.chat.CurrentAuthor = currentAuthor; 
    } 
} 

Handling the Sent Message

The user's input can be handled by hooking up to the SendMessage event of RadChat. The event arguments are of the type of SendMessageEventArgs.

Subscribing to the SendMessage event

<telerik:RadChat x:Name="chat" SendMessage="RadChat_SendMessage" /> 

SendMessage event handler

private void RadChat_SendMessage(object sender, SendMessageEventArgs e) 
{ 
    // We will handle the event in order to add a new message manually 
    e.Handled = true; 
 
    var updatedMessageText = "[Updated from event handler] " + (e.Message as TextMessage).Text; 
    this.chat.AddMessage(this.chat.CurrentAuthor, updatedMessageText); 
} 
RadChat with a message added using the SendMessage event

RadChat with a message added using the SendMessage event

Telerik UI for WinUI Learning Resources

See Also

In this article
Not finding the help you need?