Skip to content

Commit d1ae80d

Browse files
Added UG topic for Support to show error response UI
1 parent b58210e commit d1ae80d

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

MAUI/AIAssistView/items.md

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

428428
{% endhighlight %}
429429
{% endtabs %}
430+
431+
## Show error response UI
432+
433+
The `SfAIAssistView` allows to display error responses by setting the text to the `ErrorMessage`, ensuring clear notification when an error occurs during AI interactions.
434+
435+
{% tabs %}
436+
{% highlight xaml %}
437+
438+
<?xml version="1.0" encoding="utf-8" ?>
439+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
440+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
441+
xmlns:syncfusion="clr-namespace:Syncfusion.Maui.AIAssistView;assembly=Syncfusion.Maui.AIAssistView"
442+
xmlns:local="clr-namespace:MauiAIAssistView"
443+
x:Class="MauiAIAssistView.MainPage">
444+
445+
<ContentPage.BindingContext>
446+
<local:ViewModel/>
447+
</ContentPage.BindingContext>
448+
449+
<ContentPage.Content>
450+
<syncfusion:SfAIAssistView x:Name="sfAIAssistView"
451+
AssistItems="{Binding AssistItems}"/>
452+
</ContentPage.Content>
453+
</ContentPage>
454+
455+
{% endhighlight %}
456+
{% highlight c# %}
457+
458+
using Syncfusion.Maui.AIAssistView;
459+
460+
namespace MauiAIAssistView
461+
{
462+
public partial class MainPage : ContentPage
463+
{
464+
SfAiAssistView sfAIAssistView;
465+
ViewModel viewModel;
466+
public MainPage()
467+
{
468+
InitializeComponent();
469+
this.sfAIAssistView = new SfAIAssistView();
470+
this.viewModel = new ViewModel();
471+
this.sfAIAssistView.AssistItems = viewModel.AssistItems;
472+
this.Content = sfAIAssistView;
473+
}
474+
}
475+
}
476+
{% endhighlight %}
477+
{% endtabs %}
478+
479+
{% tabs %}
480+
{% highlight c# tabtitle="ViewModel.cs" hl_lines="24" %}
481+
482+
public class ViewModel : INotifyPropertyChanged
483+
{
484+
485+
...
486+
487+
private void GenerateAssistItems()
488+
{
489+
AssistItem requestItem = new AssistItem()
490+
{
491+
Text = "Hey AI, can you tell me what MAUI is? Could you provide a link to learn more about .NET MAUI?",
492+
IsRequested = true
493+
};
494+
495+
this.AssistItems.Add(requestItem);
496+
497+
await GetResult(requestItem);
498+
}
499+
500+
private async Task GetResult(AssistItem requestItem)
501+
{
502+
await Task.Delay(1000).ConfigureAwait(true);
503+
504+
AssistItem responseItem = new AssistItem()
505+
{
506+
ErrorMessage = "An error occured. Either the engine you requested does not exist or there was another issue processing your request.",
507+
IsRequested = false,
508+
};
509+
510+
this.AssistItems.Add(responseItem);
511+
512+
}
513+
}
514+
515+
{% endhighlight %}
516+
{% endtabs %}

0 commit comments

Comments
 (0)