Reduce the padding of messages

Hi how to reduce the paddding in-between messages on the SFChat control?

The gap is too far apart as per in the screenshot attached.

Attachment: Screenshot_f291087.zip

2 Replies 1 reply marked as answer

GS Gokul Saravanan Syncfusion Team November 22, 2020 05:28 PM UTC

Hi Sunny, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your query “Item spacing between messages are too large”. We would let you know currently SfChat does not provide any support to spacing between two messages. We will validate your query and let you know the further details on November 24, 2020. We appreciate your patience until then. 
 
Regards 
Gokul S 



GS Gokul Saravanan Syncfusion Team November 25, 2020 12:52 PM UTC

Hi Sunny, 
Thank you for your patience. 
 We can achieve your requirement by using custom templates for message instead of default messages template. You can refer the below code snippet to achieve your requirement 
C# 
 
  
public class MyCustomMessageTemplateSelector : ChatMessageTemplateSelector  
  {  
        private readonly DataTemplate TextTemplate;  
        public MyCustomMessageTemplateSelector(SfChat chat) : base(chat)  
        {  
            TextTemplate = new DataTemplate(() => { Label label = new Label(); label.Text = "Hard Coded text"return label; });  
        }  
  
        protected override DataTemplate OnSelectTemplate(object item, BindableObject container)  
        {  
            if (item as ITextMessage != null && (item as TextMessage).Text == "H")  
            {  
                // returns a custom rating template for this messages.  
                return TextTemplate;  
            }  
            else  
            {  
                // returns default template for all other messages.  
                return base.OnSelectTemplate(item, container);  
            }  
        }  
    }  
 
And we would let you know that we used SfListView as child of SfChat to display messages. You can also modify the ItemSpacing property of SfListView like below, 
 
SfListView list= (SfListView)(this.chat.Content as Grid).Children[0];  
list.ItemSpacing = 5; //  Set ItemsSpacing here to show modify space between messages. 
 
 
We hope this helps. Please let us know, if you would require any further assistance. 
 
Regards 
Gokul S 


Marked as answer
Loader.
Up arrow icon