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.
Figure 1: Defining CalendarMessage
Example 1: Adding a CancelResponseAction
CalendarMessage calendarMessage = new CalendarMessage(MessageDisplayPosition.Inline, otherAuthor, DateTime.Now, DateTime.Now);
calendarMessage.ReportActions.Add(new CancelResponseAction(calendarMessage, "Cancel"));
this.chat.AddMessage(calendarMessage);
Figure 2: Defining CalendarMessage with CancelResponseAction
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.
Example 2: Handling the ReportMessageResult event
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!");
}
}
}
Figure 3: Handling the ReportMessageResult
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.