I'm using RadChat control.
I use MVVM approach to bind the control's ItemSource to an ObservableCollection property in my ViewModel.
So in my xaml I have something like this:
<
telerikConversationalUI:RadChat
Author
=
"{Binding Me}"
ItemsSource
=
"{Binding Messages}"
ItemConverter
=
"{StaticResource SimpleChatItemConverter}"
SendMessageCommand
=
"{Binding SendMessageTappedCommand}"
ItemTemplateSelector
=
"{StaticResource MyChatItemTemplateSelector}"
ControlTemplate
=
"{StaticResource RadChat_ControlTemplate}"
>
In my ViewModel I have something like this:
public ObservableCollection<
CustomMessage
> Messages { set; get; }
I have CustomMessage class which contains additional properties like MessagePostedDate (which is of type DateTime, it contains the DateTime of when the message was posted)
I've also bound SendMessageCommand in RadChat control to a command (SendMessageTappedCommand) in my ViewModel.
What I've noticed is that when the Send button is tapped, the component automatically adds a new TextMessage (with Text property set to whatever the user typed) to the list, and only then does it call the SendMessageTappedCommand in my ViewModel. However, I do not want the automatic addition of a new TextMessage since I add a new CustomMessage item to Messages collection, which is bound to the RadChat control, and the SimpleChatItemConverter (which I've bound to ItemConverter of the RadChat control) converts that CustomMessage, and displays the posted date.
So the problem is everytime the user inputs a message and clicks on Send, the message ends up showing twice. First one shows up without the posted date (because a new TextMessage is automatically appended by the component), and the second message is with posted date, which was added by my SendMessageTappedCommand.
How do I stop the automatic creation of a new TextMessage when user taps on Send button?