Skip to content

Commit 90b4970

Browse files
author
Website Automation
committed
Merge remote-tracking branch 'remotes/origin/development'
2 parents 8139500 + b1e2061 commit 90b4970

File tree

212 files changed

+6935
-8760
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+6935
-8760
lines changed
17.8 KB
Loading

MAUI/AIAssistView/items.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,58 @@ The `SfAIAssistView` control includes a built-in event called [CardTapped](https
427427

428428
{% endhighlight %}
429429
{% endtabs %}
430+
431+
## Show error response
432+
433+
The `SfAIAssistView` allows to display error responses by setting the error text to the `AssistItem.ErrorMessage` property, ensuring clear notification when an error occurs during AI interactions.
434+
435+
{% tabs %}
436+
{% highlight c# tabtitle="ViewModel.cs" hl_lines="36" %}
437+
438+
public class ViewModel : INotifyPropertyChanged
439+
{
440+
441+
...
442+
443+
private void GenerateAssistItems()
444+
{
445+
AssistItem requestItem = new AssistItem()
446+
{
447+
Text = "Types of listening",
448+
IsRequested = true
449+
};
450+
451+
this.AssistItems.Add(requestItem);
452+
453+
await GetResult(requestItem);
454+
}
455+
456+
private async Task GetResultAsync(AssistItem requestItem)
457+
{
458+
try
459+
{
460+
await Task.Delay(1000);
461+
// If successful, add the normal response
462+
AssistItem responseItem = new AssistItem()
463+
{
464+
Text = "Active Listening – Fully focusing and responding to the speaker with attention and empathy. Passive Listening – Hearing without reacting or engaging with the speaker. Empathetic Listening – Understanding the speaker’s emotions and feelings deeply.",
465+
IsRequested = false,
466+
};
467+
this.AssistItems.Add(responseItem);
468+
}
469+
catch (Exception ex)
470+
{
471+
AssistItem errorItem = new AssistItem()
472+
{
473+
ErrorMessage = "An error occurred. Either the engine you requested does not exist or there was another issue processing your request.",
474+
IsRequested = false,
475+
};
476+
this.AssistItems.Add(errorItem);
477+
}
478+
}
479+
}
480+
481+
{% endhighlight %}
482+
{% endtabs %}
483+
484+
![Error message in .NET MAUI AI AssistView](images/maui-aiassistview-error-message.png)

MAUI/Chat/Scrolling.md

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,104 @@ By default, the [SfChat](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Cha
4949
{% endhighlight %}
5050
{% endtabs %}
5151

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+
![Scroll to bottom button in .NET MAUI Chat](images/scrolling/maui-chat-scroll-to-bottom-button.gif)
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.
80+
81+
{% tabs %}
82+
{% highlight xaml hl_lines="20" %}
83+
84+
<ContentPage.Resources>
85+
<ResourceDictionary>
86+
<DataTemplate x:Key="scrollToBottomButtonTemplate">
87+
<Grid>
88+
<Label Text="↓"
89+
FontSize="30"
90+
FontAttributes="Bold"
91+
HorizontalOptions="Center"
92+
VerticalOptions="Center" />
93+
...
94+
</Grid>
95+
</DataTemplate>
96+
</ResourceDictionary>
97+
</ContentPage.Resources>
98+
<ContentPage.Content>
99+
<sfChat:SfChat x:Name="sfChat"
100+
Messages="{Binding Messages}"
101+
CurrentUser="{Binding CurrentUser}"
102+
ShowScrollToBottomButton="True"
103+
ScrollToBottomButtonTemplate="{StaticResource scrollToBottomButtonTemplate}"/>
104+
</ContentPage.Content>
105+
106+
{% endhighlight %}
107+
{% highlight c# hl_lines="18" %}
108+
109+
namespace MauiChat
110+
{
111+
public partial class MainPage : ContentPage
112+
{
113+
SfChat sfChat;
114+
ViewModel viewModel;
115+
116+
public MainPage()
117+
{
118+
InitializeComponent();
119+
this.viewModel = new ViewModel();
120+
121+
this.sfChat = new SfChat
122+
{
123+
Messages = viewModel.Messages,
124+
CurrentUser = viewModel.CurrentUser,
125+
ShowScrollToBottomButton = true,
126+
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+
52150
## Scrolled event
53151

54152
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
72170
}
73171

74172
{% endhighlight %}
75-
{% endtabs %}
173+
{% endtabs %}
428 KB
Loading

0 commit comments

Comments
 (0)