# Show desktop alert with message in RadChat

## Environment

<table>
	<tr>
		<td>Product</td>
		<td>RadChat for WPF</td>
	</tr>
</table>

## Description

How to display alert, when a message is sent.

## Solution

Handle the **SendMessage** event of the RadChat control, create a [RadDesktopAlert](https://www.telerik.com/products/wpf/documentation/controls/raddesktopalert/getting-started) and set its Content to a new **MessageGroupViewModel**. We are going to use the **MessageGroup** control to display the new message in the alert, however it can be replaced by a custom DataTemplate as well.

```XAML
	<Grid xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
         xmlns:chat="clr-namespace:Telerik.Windows.Controls.ConversationalUI;assembly=Telerik.Windows.Controls.ConversationalUI" 
         x:Name="grid">
        <Grid.Resources>
            <DataTemplate x:Key="ChatTemplate">
                <chat:MessageGroup />
            </DataTemplate>
        </Grid.Resources>
        <telerik:RadChat x:Name="chat" SendMessage="chat_SendMessage" />
    </Grid>
```

```C#
    private void chat_SendMessage(object sender, SendMessageEventArgs e)
    {
        RadDesktopAlertManager manager = new RadDesktopAlertManager(AlertScreenPosition.BottomRight, new Point(0, 0), 10);
        var chat = sender as RadChat;
        var viewmodel = new MessageGroupViewModel(e.Message.Author);
        viewmodel.Messages.Add((e.Message as IInlineMessage).InlineViewModel);
        
        var alert = new RadDesktopAlert
        {
            Header = chat.CurrentAuthor.Name,
            Content = viewmodel,
            ContentTemplate = this.grid.FindResource("ChatTemplate") as DataTemplate,
            ShowDuration = 5000,
        };

        manager.ShowAlert(alert);
    }
```

## See Also

* [RadChat](https://www.telerik.com/products/wpf/documentation/controls/radchat/getting-started)
