You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MAUI/Chat/scrolling.md
+99-1Lines changed: 99 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,104 @@ By default, the [SfChat](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Cha
49
49
{% endhighlight %}
50
50
{% endtabs %}
51
51
52
+
## Scroll to bottom button
53
+
54
+
The `SfChat` control provides the option to display a scroll to bottom button by setting the `ShowScrollToBottomButton` property to `true`. This button appears when scrolled up through older messages and allows quick navigation back to the latest message in the conversation.
55
+
56
+
{% tabs %}
57
+
{% highlight xaml hl_lines="4" %}
58
+
<sfChat:SfChat x:Name="sfChat"
59
+
Messages="{Binding Messages}"
60
+
CurrentUser="{Binding CurrentUser}"
61
+
ShowScrollToBottomButton="True"/>
62
+
63
+
{% endhighlight %}
64
+
{% highlight c# hl_lines="5" %}
65
+
66
+
SfChat sfChat = new SfChat();
67
+
ViewModel viewModel = new ViewModel();
68
+
sfChat.Messages = viewModel.Messages;
69
+
sfChat.CurrentUser = viewModel.CurrentUser;
70
+
sfChat.ShowScrollToBottomButton = true;
71
+
72
+
{% endhighlight %}
73
+
{% endtabs %}
74
+
75
+

76
+
77
+
### Scroll to bottom button customization
78
+
79
+
The `SfChat` control allows you to fully customize the scroll to bottom button appearance by using the `ScrollToBottomButtonTemplate` property. This property lets you define a custom view and style.
ScrollToBottomButtonTemplate = new DataTemplate(() =>
127
+
{
128
+
var grid = new Grid();
129
+
var label = new Label
130
+
{
131
+
Text = "↓",
132
+
FontSize = 30,
133
+
FontAttributes = FontAttributes.Bold,
134
+
HorizontalOptions = LayoutOptions.Center,
135
+
VerticalOptions = LayoutOptions.Center
136
+
};
137
+
grid.Children.Add(label);
138
+
return grid;
139
+
})
140
+
};
141
+
142
+
this.Content = sfChat;
143
+
}
144
+
}
145
+
}
146
+
147
+
{% endhighlight %}
148
+
{% endtabs %}
149
+
52
150
## Scrolled event
53
151
54
152
The [SfChat](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Chat.SfChat.html) control comes with a built-in `Scrolled` event that will be fired whenever the chat control is scrolled. You can get the current scroll offset, whether scrolling has reached the top or bottom of the message list in the [ChatScrolledEventArgs](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Chat.ChatScrolledEventArgs.html). You can handle this event to restrict the auto-scroll in chat for newly added messages, if the user had already scrolled up manually and was currently not at the bottom of the chat when the new message was added.
@@ -72,4 +170,4 @@ The [SfChat](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Chat.SfChat.htm
0 commit comments