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

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.

CalendarMessage CalendarMessage

Adding a CancelResponseAction

CalendarMessage calendarMessage = new CalendarMessage(MessageDisplayPosition.Inline, this.currentAuthor); 
calendarMessage.ReportActions.Add(new CancelResponseAction(calendarMessage, "Cancel")); 
 
this.chat.AddMessage(calendarMessage); 
Adding a CancelResponseAction will have the following output.

CalendarMessage with a CancelResponseAction CalendarMessage with a CancelResponseAction

Handling the Response

The user's interaction is handled through the ReportMessageResult event. Its event arguments are of the type of MessageResultEventArgs and expose the following properties:

  • 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.

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!"); 
        } 
    } 
} 
So, if the user clicks the Submit button for the previously defined CalendarMessage the result will be as in the figure below.

Handling the ReportMessageResult 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.

In this article
Not finding the help you need?