This is a migrated thread and some comments may be shown as answers.

Chat - Missing message name

9 Answers 139 Views
Conversational UI, Chat
This is a migrated thread and some comments may be shown as answers.
Nicklas
Top achievements
Rank 1
Nicklas asked on 10 Jul 2019, 12:11 AM

I've created a chat, and are now about to set the last touch on the UI and what not. I'm trying to achieve a behavior that enables name on all of the messages (including the latest)

 

I've attached a image for better understaind.

 

Thanks in advance.

9 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 10 Jul 2019, 01:40 PM
Hello Nicklas,

You can use the ItemFormatting event to show the name label:
private void RadChat1_ItemFormatting(object sender, ChatItemElementEventArgs e)
{
    var messageElement = e.ItemElement as TextMessageItemElement;
    if (messageElement != null)
    {
 
        messageElement.NameLabelElement.Visibility = ElementVisibility.Visible;
    }
}

I hope this helps. Should you have any other questions, do not hesitate to ask.
 
Regards,
Dimitar
Progress TelerikRadChat for Winforms
0
Nicklas
Top achievements
Rank 1
answered on 10 Jul 2019, 02:03 PM
Is there another way without using a event to achieve the desired behavior? - This is a chat using TCP/IP protocol witch main purpose is to enable agents, using this system, to chat with each other. I'm asking because it's bad practise to populate controls inside an event like this. Also the function needs to be called from buttons too.
0
Dimitar
Telerik team
answered on 11 Jul 2019, 08:41 AM
Hello Niclas,

This is not possible. We are using UI Virtualization which means that the items are updated at runtime, while scrolling for example. To use it from a button add a conditional property for this and refresh the controls with the following method:
private void RadButton3_Click(object sender, EventArgs e)
{
    var view = radChat1.ChatElement.MessagesViewElement as ChatMessagesViewElement;
    view.Update(ChatMessagesViewElement.UpdateModes.RefreshAll);
 
}

I hope this helps. Should you have any other questions, do not hesitate to ask.

Regards,
Dimitar
Progress TelerikRadChat for Winforms
0
Nicklas
Top achievements
Rank 1
answered on 11 Jul 2019, 01:11 PM

Hello again and thanks for your reply. 

I don't see how this can achieve the desired behavior as I cannot access the NameLabelElement by using this "var view = radChat1.ChatElement.MessagesViewElement as ChatMessagesViewElement;"?

0
Dimitar
Telerik team
answered on 15 Jul 2019, 08:34 AM
Hi Niclas,

I have attached my test project. It shows the approach that you can use to show hide the labels. 

Let me know which part is not working for your requirement. 

Regards,
Dimitar
Progress TelerikRadChat for Winforms
0
Nicklas
Top achievements
Rank 1
answered on 15 Jul 2019, 01:04 PM

The behavior is what I am looking for indeed, but I'm trying to implement the behavior on the chat 'SendMessage' event. The problem is that the AutoAddUserMessages property has to be set to true, and by doing that this solution seems to be excluded to me.I know the chat is not designed for real-time chat, but I think it's very hard to work with it in that relation because of asyc blocks, and the fact that many properties can only be set throw events. But thanks for your answer.

 

0
Dimitar
Telerik team
answered on 16 Jul 2019, 06:08 AM
Hello Nicklas,

This is done for performance reason and to separate the UI from the actual data. Since R3 2018 we exposed a UserData property in all message types. You can use this property to pas any additional information and then parse it when the message is received and set the visual properties as well. 

Let me know if I can assist you further.

Regards,
Dimitar
Progress TelerikRadChat for Winforms
0
Nicklas
Top achievements
Rank 1
answered on 17 Jul 2019, 02:15 PM

Hello again,

Yes that makes sense - I've been noticing the UserData property, but I couldn't find any documentation on it. Can you please provide a short example code?

 

Thanks in advance.

0
Dimitar
Telerik team
answered on 18 Jul 2019, 08:40 AM

Hi Nicklas,

Yes, I have attached a sample project.

I hope this helps. 

Regards, Dimitar
Progress Telerik

RadChat for Winforms

Tags
Conversational UI, Chat
Asked by
Nicklas
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Nicklas
Top achievements
Rank 1
Share this question
or