Edit this page

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 />

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

[C#] Example 3: Adding Authors to RadChat

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

public partial class MainWindow : Window
{
    private Author currentAuthor;
    private Author otherAuthor;

    public MainWindow()
    {
        InitializeComponent();

        currentAuthor = new Author("1") { Name = "Peter" };
        otherAuthor = new Author("2") { Name = "Steven" };
        this.chat.CurrentAuthor = currentAuthor;
    }
}

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

 private void Chat_SendMessage_(object sender, SendMessageEventArgs e)
    {
        var author = e.Message.Author;
        if (author == this.chat.CurrentAuthor)
        {
            this.chat.AddMessage(this.currentAuthor, (e.Message as TextMessage).Text);
            this.chat.AddMessage(this.otherAuthor, (e.Message as TextMessage).Text);

            e.Handled = true;
        }
    }

This setup will have the following result.

Figure 2: RadChat with Messages

RadChat with Messages

See Also

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy