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