# 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](https://www.telerik.com/winui/documentation/installation-and-deployment/systemrequirements).

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

   * [Getting Started with NuGet](https://www.telerik.com/winui/documentation/getting-started/first-steps-nuget#step-2-create-the-winui-application)

   * [Getting Started with the MSI file](https://www.telerik.com/winui/documentation/getting-started/first-steps-msi#step-2-create-the-winui-application)

   * [Getting Started with the ZIP file](https://www.telerik.com/winui/documentation/getting-started/first-steps-zip#step-2-create-the-winui-application)

   * [Getting Started with the Telerik UI Visual Studio Extension](https://www.telerik.com/winui/documentation/getting-started/first-steps-vsextension#step-2-create-the-winui-application)

## Add the Assembly References

To use the RadChat component, add references to `Telerik.WinUI.Controls.dll` and `Telerik.Licensing.Runtime.dll`.

## Define the Component

To use the control, create a new RadChat instance.

#### **Defining RadChat**

```XAML
<telerik:RadChat x:Name="chat"/>
```

**Empty RadChat**

![Empty RadChat](https://www.telerik.com/winui/documentation/assets/495a9f6726f1156775730b4e116785e8/radchat-getting-started-0.png)

## 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**

```C#
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**

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

#### **SendMessage event handler**

```C#
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](https://www.telerik.com/winui/documentation/assets/9dadab1ad87bbcad4c9d049a4ba28388/radchat-getting-started-1.png)

## Telerik UI for WinUI Learning Resources

* [Telerik UI for WinUI Chat Component](https://www.telerik.com/winui/chat)
* [Getting Started with Telerik UI for WinUI Components](https://www.telerik.com/winui/documentation/getting-started/first-steps-nuget)
* [Telerik UI for WinUI Installation](https://www.telerik.com/winui/documentation/installation-and-deployment/installing-which-file-do-i-need)
* [Telerik UI for WinUI Examples](https://www.telerik.com/winui/documentation/examples/demos-app)
* [Telerik UI for WinUI Accessibility](https://www.telerik.com/winui/documentation/common/accessibility)
* [Telerik UI for WinUI License Agreement](https://www.telerik.com/purchase/license-agreement/winui)

## See Also

* [Visual Structure](https://www.telerik.com/winui/documentation/controls/radchat/visual-structure)
