|
1 | 1 | # show-scrollbar-chat-xamarin-forms |
2 | | -How to show the ScrollBar in Xamarin.Forms Chat (SfChat) |
| 2 | +This sample demonstrates how to show the ScrollBar in Xamarin.Forms Chat (SfChat). |
| 3 | + |
| 4 | +## Sample |
| 5 | + |
| 6 | +```xaml |
| 7 | + |
| 8 | + <ContentPage.Content> |
| 9 | + <sfChat:SfChat x:Name="sfChat" |
| 10 | + Messages="{Binding Messages}" |
| 11 | + CurrentUser="{Binding CurrentUser}" |
| 12 | + ShowIncomingMessageAvatar="True" |
| 13 | + ShowOutgoingMessageAvatar="True"> |
| 14 | + <sfChat:SfChat.Behaviors> |
| 15 | + <local:SfchatBehaviors/> |
| 16 | + </sfChat:SfChat.Behaviors> |
| 17 | + </sfChat:SfChat> |
| 18 | + </ContentPage.Content> |
| 19 | + |
| 20 | +Behavior: |
| 21 | + |
| 22 | + public class SfchatBehaviors : Behavior<SfChat> |
| 23 | + { |
| 24 | + #region Fields |
| 25 | + |
| 26 | + private SfChat sfChat = null; |
| 27 | + private SfListView ChatListView = null; |
| 28 | + |
| 29 | + #endregion |
| 30 | + |
| 31 | + #region Overrides |
| 32 | + |
| 33 | + protected override void OnAttachedTo(SfChat bindable) |
| 34 | + { |
| 35 | + base.OnAttachedTo(bindable); |
| 36 | + sfChat = bindable; |
| 37 | + if (sfChat != null) |
| 38 | + { |
| 39 | + ChatListView = (sfChat.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name.Equals("ChatListView")).GetValue(sfChat) as SfListView); |
| 40 | + if (ChatListView != null) |
| 41 | + { |
| 42 | + ChatListView.IsScrollBarVisible = true; |
| 43 | + } |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + protected override void OnDetachingFrom(SfChat bindable) |
| 48 | + { |
| 49 | + base.OnAttachedTo(bindable); |
| 50 | + ChatListView = null; |
| 51 | + sfChat = null; |
| 52 | + } |
| 53 | + |
| 54 | + #endregion |
| 55 | + } |
| 56 | + |
| 57 | +``` |
| 58 | +## Requirements to run the demo |
| 59 | + |
| 60 | +To run the demo, refer to [System Requirements for Xamarin](https://help.syncfusion.com/xamarin/system-requirements) |
| 61 | + |
| 62 | +## Troubleshooting |
| 63 | + |
| 64 | +### Path too long exception |
| 65 | + |
| 66 | +If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project. |
| 67 | + |
| 68 | + |
0 commit comments