title | description | type | page_title | slug | position | tags | ticketid | res_type |
---|---|---|---|---|---|---|---|---|
Show desktop alert with message in RadChat |
Display alert for sent message in RadChat. |
how-to |
Create a popup for new message in ConversationalUI |
kb-chat-showing-message-desktop-alert |
0 |
chat, desktopalert, show, message |
1408996 |
kb |
Product | RadChat for WPF |
How to display alert, when a message is sent.
Handle the SendMessage event of the RadChat control, create a [RadDesktopAlert]({%slug 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.
{{region kb-chat-showing-message-desktop-alert-0}} <Grid.Resources> <chat:MessageGroup /> </Grid.Resources> <telerik:RadChat x:Name="chat" SendMessage="chat_SendMessage" /> {{endregion}}
{{region kb-chat-showing-message-desktop-alert-1}} 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);
}
{{endregion}}
- [RadChat]({%slug chat-getting-started%})