Declined
Last Updated: 07 Jun 2019 11:48 by ADMIN
Hemesh
Created on: 07 Jun 2019 06:52
Category: UI for WinForms
Type: Bug Report
0
radchat- highlighting a message in chat.

Hello,

I have already used your ItemFormatting event in my code and implemented it the same way you have provided.

In my code, i have created 7-8 messages and fixed the first msg's timestamp to "6/6/2019 11:53:08 AM" and the remaining messages with timestamp of 2 minutes more than this time. Whenever the event is triggered i wrote a code which compares the timestamp of my message with this timestamp "6/6/2019 11:53:08 AM". Conditionally only the first message falls in this condition and i paint it red, which works well for first time (On load) and then when i scroll my chat, the event unnecessarily paints the remaining msgs too, which should not happen.

I am attaching my .cs file with designer please refer to it, and resolve this asap. Looking forward to your response.

Thanks.

Attached Files:
1 comment
ADMIN
Nadya | Tech Support Engineer
Posted on: 07 Jun 2019 11:48
Hello Hemesh,

By using ItemFormatting event to customize the items appearance, you should always provide an else clause, where you reset the appearance settings which you have introduced. Please, refer to the following code snippet. This is necessary since RadChat uses UI Virtualization, this means that we will create visual elements only for the currently visible messages. These visual elements are reused when scrolling for example. Ans this is why you need to reset any changed properties:
private void radChat1_ItemFormatting(object sender, ChatItemElementEventArgs e)
{
    TextMessageItemElement textItemElement = e.ItemElement as TextMessageItemElement;
    if (textItemElement != null)
    {
        TextMessageDataItem obj = textItemElement.Data as TextMessageDataItem;
        string Msg = obj.TextMessage.Message;
        ChatTextMessage msg = obj.Message as ChatTextMessage;
 
        if (msg.TimeStamp.Equals(dt))
        {
            e.ItemElement.ForeColor = Color.Red;
        }
        else
        {
            e.ItemElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
        }
    }
    else
    {
        e.ItemElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
    }
 
}

Have in mind that it is absolutely normal that the ItemFormatting event is fired a lot of times. Due to the UI virtualization of the visual elements, this event ensures that the proper style will be applied to the items.

Please note that this is not an issue with the suite I will set the item status to declined.

I hope this information helps. If you need any further assistance please don't hesitate to contact me.

Regards,
Nadya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.