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

Getting Started

This topic will guide you through the process of creating a sample application containing RadChat.

Assembly References

  • Telerik.Windows.Controls
  • Telerik.Windows.Controls.Input
  • Telerik.Windows.Controls.Navigation
  • Telerik.Windows.Controls.ConversationalUI

Adding RadChat to the Project

Before proceeding with adding RadChat to your project, make sure the required assembly references are added to the project.

You can add Conversational UI manually by writing the XAML code in Example 1. You can also add the control by dragging it from the Visual Studio Toolbox and dropping it over the XAML view.

Example 1: Adding RadChat in XAML

<telerik:RadChat x:Name="chat" /> 
Running the application at this state will result in an empty chat.

Figure 1: The Empty Chat Generated by the Code in Example 1

Empty RadChat

Adding Authors to RadChat

Two authors will be defined for this example. Note, that the CurrentAuthor property of RadChat must be set.

Example 3: Adding Authors to RadChat

public partial class MainWindow : Window 
    private Author currentAuthor; 
    private Author otherAuthor; 
    public MainWindow() 
        currentAuthor = new Author("Peter"); 
        otherAuthor = new Author("Steven"); = currentAuthor; 
Partial Public Class MainWindow 
    Inherits Window 
        Private currentAuthor As Author 
        Private otherAuthor As Author 
        Public Sub New() 
            currentAuthor = New Author("Peter") 
            otherAuthor = New Author("Steven") 
   = currentAuthor 
        End Sub 
End Class 

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 type RoutedEventArgs which are extended by the Message property.

Example 4: Subscribing to the SendMessage event

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

Example 5: SendMessage event handler

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;, updatedMessageText); 
Private Sub RadChat_SendMessage(ByVal sender As Object, ByVal e As SendMessageEventArgs) 
    ' We will handle the event in order to add a new message manually 
    e.Handled = True 
    Dim updatedMessageText = "[Updated from event handler] " & (TryCast(e.Message, TextMessage)).Text, updatedMessageText) 
End Sub 

This setup will have the following result.

Figure 2: RadChat with Messages

RadChat with Messages

See Also

In this article
Not finding the help you need? Improve this article