Skip to content

Commit edd79a2

Browse files
Merge pull request #3901 from syncfusion-content/assistviewUG_Vol4
Prepare UG documentation for 2025 Volume 4 features - MAUI AssistView, TreeView
2 parents 6440bd9 + 9a6e486 commit edd79a2

File tree

8 files changed

+424
-15
lines changed

8 files changed

+424
-15
lines changed
59.7 KB
Loading
224 KB
Loading
8.96 KB
Loading
99.6 KB
Loading
30 KB
Loading

MAUI/AIAssistView/items.md

Lines changed: 164 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,167 @@ public class ViewModel : INotifyPropertyChanged
481481
{% endhighlight %}
482482
{% endtabs %}
483483

484-
![Error message in .NET MAUI AI AssistView](images/maui-aiassistview-error-message.png)
484+
![Error message in .NET MAUI AI AssistView](images/maui-aiassistview-error-message.png)
485+
486+
## Customizable views
487+
488+
The `SfAIAssistView` allows you to customize specific parts of request and response items without changing the entire UI. You can apply styles, templates, or subclass these views to create custom visuals and behavior.
489+
490+
The following views can be customized individually:
491+
492+
- `RequestTextView` – Represents the user request text content.
493+
- `RequestAssistImageView` – Represents the user request image content.
494+
- `RequestHyperlinkUrlLabelView` – Represents the user request URL label area.
495+
- `RequestHyperLinkDetailsViewFrameView` – Represents the user request URL details/preview frame area.
496+
- `ResponseTextView` – Represents the AI response text content.
497+
- `ResponseAssistImageView` – Represents the AI response image content.
498+
- `ResponseHyperlinkUrlLabelView` – Represents the AI response URL label area.
499+
- `ResponseHyperLinkDetailsViewFrameView` – Represents the AI response URL details/preview frame area.
500+
- `ResponseCardView` – Represents the container for card-based AI responses.
501+
- `CardItemView` – Represents a single card item within a response.
502+
- `CardButtonView` – Represents an action button inside a card item; exposes Title and Value bindable properties
503+
504+
{% tabs %}
505+
{% highlight xaml hl_lines="12 27" %}
506+
507+
<?xml version="1.0" encoding="utf-8"?>
508+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
509+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
510+
xmlns:syncfusion="clr-namespace:Syncfusion.Maui.AIAssistView;assembly=Syncfusion.Maui.AIAssistView"
511+
x:Class="MauiAIAssistView.MainPage">
512+
513+
<ContentPage.BindingContext>
514+
<local:ViewModel/>
515+
</ContentPage.BindingContext>
516+
517+
<ContentPage.Resources>
518+
<ResourceDictionary>
519+
<!-- Request text customization -->
520+
<Style TargetType="syncfusion:RequestTextView">
521+
<Setter Property="ControlTemplate">
522+
<Setter.Value>
523+
<ControlTemplate>
524+
<Grid Padding="8" BackgroundColor="{DynamicResource SecondaryContainer}">
525+
<Label
526+
Text="{Binding Text}"
527+
FontSize="13"
528+
TextColor="{DynamicResource OnSecondaryContainer}" />
529+
</Grid>
530+
</ControlTemplate>
531+
</Setter.Value>
532+
</Setter>
533+
</Style>
534+
535+
<!-- Response text customization -->
536+
<Style TargetType="syncfusion:ResponseTextView">
537+
<Setter Property="ControlTemplate">
538+
<Setter.Value>
539+
<ControlTemplate>
540+
<Grid Padding="10" BackgroundColor="{DynamicResource PrimaryContainer}">
541+
<Label
542+
Text="{Binding Text}"
543+
FontSize="13"
544+
FontAttributes="Italic"
545+
TextColor="{DynamicResource OnPrimaryContainer}" />
546+
</Grid>
547+
</ControlTemplate>
548+
</Setter.Value>
549+
</Setter>
550+
</Style>
551+
...
552+
</ResourceDictionary>
553+
</ContentPage.Resources>
554+
555+
<ContentPage.Content>
556+
<syncfusion:SfAIAssistView x:Name="AssistView"
557+
AssistItems="{Binding AssistItems}" />
558+
</ContentPage.Content>
559+
</ContentPage>
560+
561+
{% endhighlight %}
562+
{% highlight c# hl_lines="18 41" %}
563+
564+
using Syncfusion.Maui.AIAssistView;
565+
566+
namespace MauiAIAssistView
567+
{
568+
public partial class MainPage : ContentPage
569+
{
570+
SfAIAssistView assistView;
571+
ViewModel viewModel;
572+
573+
public MainPage()
574+
{
575+
InitializeComponent();
576+
viewModel = new ViewModel();
577+
578+
assistView = new SfAIAssistView
579+
{
580+
AssistItems = viewModel.AssistItems;
581+
};
582+
583+
var resources = new ResourceDictionary();
584+
585+
// Request text customization
586+
var requestTextStyle = new Style(typeof(RequestTextView))
587+
{
588+
Setters =
589+
{
590+
new Setter
591+
{
592+
Property = RequestTextView.ControlTemplateProperty,
593+
Value = new ControlTemplate(() =>
594+
{
595+
var grid = new Grid { Padding = 8, BackgroundColor = Colors.Beige };
596+
var label = new Label
597+
{
598+
FontSize = 13,
599+
TextColor = Colors.Black
600+
};
601+
label.SetBinding(Label.TextProperty, "Text");
602+
grid.Children.Add(label);
603+
return grid;
604+
})
605+
}
606+
}
607+
};
608+
609+
// Response text customization
610+
var responseTextStyle = new Style(typeof(ResponseTextView))
611+
{
612+
Setters =
613+
{
614+
new Setter
615+
{
616+
Property = ResponseTextView.ControlTemplateProperty,
617+
Value = new ControlTemplate(() =>
618+
{
619+
var grid = new Grid { Padding = 10, BackgroundColor = Colors.LightSkyBlue };
620+
var label = new Label
621+
{
622+
FontSize = 13,
623+
FontAttributes = FontAttributes.Italic,
624+
TextColor = Colors.White
625+
};
626+
label.SetBinding(Label.TextProperty, "Text");
627+
grid.Children.Add(label);
628+
return grid;
629+
})
630+
}
631+
}
632+
};
633+
634+
...
635+
636+
resources.Add(requestTextStyle);
637+
resources.Add(responseTextStyle);
638+
639+
this.Resources = resources;
640+
this.Content = assistView;
641+
this.BindingContext = viewModel;
642+
}
643+
}
644+
}
645+
646+
{% endhighlight %}
647+
{% endtabs %}

0 commit comments

Comments
 (0)