Skip to content

Commit 0d285cf

Browse files
Addressed review corrections
1 parent 2706b2c commit 0d285cf

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

MAUI/Chat/scrolling.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,32 @@ The [SfChat](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Chat.SfChat.htm
7979
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.
8080

8181
{% tabs %}
82-
{% highlight xaml tabtitle="MainPage.xaml" hl_lines="4" %}
82+
{% highlight xaml hl_lines="4" %}
8383
<sfChat:SfChat x:Name="sfChat"
8484
Messages="{Binding Messages}"
8585
CurrentUser="{Binding CurrentUser}"
8686
ShowScrollToBottomButton="True"/>
8787

88+
{% endhighlight %}
89+
{% highlight c# hl_lines="5" %}
90+
91+
SfChat sfChat = new SfChat();
92+
ViewModel viewModel = new ViewModel();
93+
sfChat.Messages = viewModel.Messages;
94+
sfChat.CurrentUser = viewModel.CurrentUser;
95+
sfChat.ShowScrollToBottomButton = true;
96+
8897
{% endhighlight %}
8998
{% endtabs %}
9099

91100
![Scroll to bottom button in .NET MAUI Chat](images/scrolling/maui-chat-scroll-to-bottom-button.gif)
92101

93102
### Scroll to Bottom Button Template
94103

95-
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 layout and style.
104+
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.
96105

97106
{% tabs %}
98-
{% highlight xaml tabtitle="MainPage.xaml" hl_lines="20" %}
107+
{% highlight xaml hl_lines="20" %}
99108

100109
<ContentPage.Resources>
101110
<ResourceDictionary>
@@ -119,5 +128,46 @@ The `SfChat` control allows you to fully customize the scroll to bottom button a
119128
ScrollToBottomButtonTemplate="{StaticResource scrollToBottomButtonTemplate}"/>
120129
</ContentPage.Content>
121130

131+
{% endhighlight %}
132+
{% highlight c# hl_lines="18" %}
133+
134+
namespace MauiChat
135+
{
136+
public partial class MainPage : ContentPage
137+
{
138+
SfChat sfChat;
139+
ViewModel viewModel;
140+
141+
public MainPage()
142+
{
143+
InitializeComponent();
144+
this.viewModel = new ViewModel();
145+
146+
this.sfChat = new SfChat
147+
{
148+
Messages = viewModel.Messages,
149+
CurrentUser = viewModel.CurrentUser,
150+
ShowScrollToBottomButton = true,
151+
ScrollToBottomButtonTemplate = new DataTemplate(() =>
152+
{
153+
var grid = new Grid();
154+
var label = new Label
155+
{
156+
Text = "↓",
157+
FontSize = 30,
158+
FontAttributes = FontAttributes.Bold,
159+
HorizontalOptions = LayoutOptions.Center,
160+
VerticalOptions = LayoutOptions.Center
161+
};
162+
grid.Children.Add(label);
163+
return grid;
164+
})
165+
};
166+
167+
this.Content = sfChat;
168+
}
169+
}
170+
}
171+
122172
{% endhighlight %}
123173
{% endtabs %}

0 commit comments

Comments
 (0)