# Message Reports

## Default Response Actions

Interacting with the messages of **RadChat** is done through **ResponseAction** objects. There are two predefined ones for the **Commit** and **Cancel** operations. They should be added to the **ReportActions** collection of the given message. Each **ReportAction** can have its **Message** and **Text** properties set.

* **CommitResponseAction**
* **CancelResponseAction**

Their visual representation may vary depending on the type of message. For example, the default **CommitResponseAction** that is defined for the **CalendarMessage** would appear as a **Submit** button shown below.

> caption Defining CalendarMessage

![CalendarMessage](https://www.telerik.com/products/wpf/documentation/assets/1701c9e39c7fbe81d1775cc714e41e57/radchat_messages_reports_01.png)

**Adding a CancelResponseAction**

```C#
CalendarMessage calendarMessage = new CalendarMessage(MessageDisplayPosition.Inline, otherAuthor, DateTime.Now, DateTime.Now);
calendarMessage.ReportActions.Add(new CancelResponseAction(calendarMessage, "Cancel"));
this.chat.AddMessage(calendarMessage);
```

Adding a **CancelResponseAction** will have the following output.

> caption Defining CalendarMessage with CancelResponseAction

![CalendarMessage with CancelResponseAction](https://www.telerik.com/products/wpf/documentation/assets/a0e5ed3007f65fcc4d000022ffa75640/radchat_messages_reports_02.png)

## Handling the Response

The user's interaction is handled through the **ReportMessageResult** event. Its arguments expose the following properties.

> The **ReportMessageResult** is raised only for the built-in **ResponseActions**.

* **Message**: Provides information regarding the message that raises the current report.
* **TextMessageResult**: The result that will be posted as a text message can be controlled through it.
* **PropertyName**: Provides information of the property that has been edited. For example, for a **CalendarMessage** it would be the **SelectedDate** property.
* **DataObjectResult**: The data object value of the posted result.
* **PostResultInline**: A boolean property that indicates whether the text result should be posted as an inline message.
* **CloseAfterReport**: A boolean property that controls whether the message should be removed after the report.
* **MessageReportType**: Gets the message report type. It is of enum type and can either have a **Commit** or **Cancel** value.

As an example, lets have the following implementation of the event.
**Handling the ReportMessageResult Event**

```C#
private void chat_ReportMessageResult(object sender, MessageResultEventArgs e)
{
    if (e.Message is CalendarMessage)
    {
        if (e.ReportType == MessageReportType.Commit)
        {
            e.PostResultInline = true;
            e.CloseAfterReport = true;
            this.chat.AddMessage(this.otherAuthor, "Accepted!");
        }
        else if (e.ReportType == MessageReportType.Cancel)
        {
            e.CloseAfterReport = true;
            this.chat.AddMessage(this.otherAuthor, "Canceled!");
        }
    }
}
```

So, if the user clicks the **Submit** button for the previously defined **CalendarMessage** the result will be as in the figure below.

> caption Handling the ReportMessageResult

![CalendarMessage with CancelResponseAction](https://www.telerik.com/products/wpf/documentation/assets/53b2e52c5a502c40e1d0636882959545/radchat_messages_reports_03.png)

## Custom ResponseAction

A custom **ResponseAction** provides the ability to trigger a custom **ICommand** instead of handling the Response through the **ReportMessageResult** event. This is done by inheriting the abstract **ResponseAction** object.

## See Also

* [Messages Overview](https://www.telerik.com/products/wpf/documentation/controls/radchat/messages/overview)
