Category / Section
How to show the ScrollBar in Xamarin.Forms Chat (SfChat)
1 min read
SfChat does not have any direct support for showing the scrollbar in view. However, it can be achieved by setting the value as true to IsScollBarVisible property of ChatListView in SfChat.
XAML
Define the behavior for the SfChat.
<sfChat:SfChat x:Name="sfChat" Messages="{Binding Messages}" CurrentUser="{Binding CurrentUser}" ShowIncomingMessageAvatar="True" ShowOutgoingMessageAvatar="True"> <sfChat:SfChat.Behaviors> <local:SfchatBehaviors/> </sfChat:SfChat.Behaviors> </sfChat:SfChat>
C#
Set the IsScrollBarVisible property value to true in the ChatListView Loaded event.
public class SfchatBehaviors : Behavior<SfChat> { private SfChat sfChat = null; private SfListView ChatListView = null; protected override void OnAttachedTo(SfChat bindable) { base.OnAttachedTo(bindable); sfChat = bindable; if (sfChat != null) { ChatListView = (sfChat.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name.Equals("ChatListView")).GetValue(sfChat) as SfListView); if (ChatListView != null) { ChatListView.IsScrollBarVisible = true; } } } protected override void OnDetachingFrom(SfChat bindable) { base.OnAttachedTo(bindable); ChatListView = null; sfChat = null; } }
Take a moment to pursue the documentation, where you can find more about SfChat with code examples