Skip to content

Latest commit

 

History

History
66 lines (55 loc) · 2.16 KB

kb-chat-showing-message-desktop-alert.md

File metadata and controls

66 lines (55 loc) · 2.16 KB
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

Environment

Product RadChat for WPF

Description

How to display alert, when a message is sent.

Solution

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.

[XAML]

{{region kb-chat-showing-message-desktop-alert-0}} <Grid.Resources> <chat:MessageGroup /> </Grid.Resources> <telerik:RadChat x:Name="chat" SendMessage="chat_SendMessage" /> {{endregion}}

[C#]

{{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}}

See Also

  • [RadChat]({%slug chat-getting-started%})