# Time Break

The **TimeBreak** mechanism of **RadChat** is intended to encapsulate a group of messages for a given time interval. It can be either added manually or automatically.

## Adding a TimeBreak Automatically

**RadChat** can automatically add a TimeBreak at a given interval. This can achieved by setting the **AutoIncludeTimeBreaks** boolean property of **RadChat** to **True**. Also, the needed **TimeSpan** needs to be set to the **TimeBreakInterval** property of the control.

## Adding a TimeBreak Manually

**RadChat** provides the **AddTimeBreak** method for adding a **TimeBreak** which accepts a string parameter for its header.

**Adding TimeBreak**

```C#
var firstTextMessage = new TextMessage(this.otherAuthor, "Hello Peter! How are you?");
var secondTextMessage = new TextMessage(this.otherAuthor, "I hope I find you well!");
var thirdTextMessage = new TextMessage(this.otherAuthor, "How is family? ");

this.chat.AddMessage(firstTextMessage);
this.chat.AddMessage(secondTextMessage);
this.chat.AddMessage(thirdTextMessage);

this.chat.AddTimeBreak(DateTime.Now.DayOfWeek.ToString() + " " + DateTime.Now.TimeOfDay.Hours.ToString() + " : " + DateTime.Now.TimeOfDay.Minutes.ToString());
```

> caption Adding a TimeBreak

![Adding a TimeBreak](https://www.telerik.com/products/wpf/documentation/assets/61f64f5849cb38e1f26784ef1ef8f107/radchat_timebreak_01.png)

## Handling the AddingTimeBreak Event

The **AddingTimeBreak** event provides various information regarding the last **MessageGroup** and the **Messages** in it. Also, the event can be canceled. The following event arguments are exposed for this purpose.

* **Cancel**: The event can be canceled by setting the property to **True**.
* **Header**: Provides information regarding the current **Header** that is to be set for the **TimeBreak**.
* **LastMessageGroup**

The **LastMessageGroup** itself provides the following information.

* **Alignment**: Gets the alignment of the **MessageGroup**.
* **Author**: The group's **Author**.
* **AvatarAlignment**: Gets the alignment of the **Avatar** according to the **CurrentAuthor**.
* **CreationDate**: Gets the time when the first **Message** of the group was created.
* **Messages**: The collection of all messages within the group.

## See Also

* [Getting Started](https://www.telerik.com/products/wpf/documentation/controls/radchat/getting-started)
* [Typing Indicator](https://www.telerik.com/products/wpf/documentation/controls/radchat/typing-indicator)
* [Suggested Actions](https://www.telerik.com/products/wpf/documentation/controls/radchat/suggested-actions)
