This demo explains about how to customize the appearance using control template in .NET MAUI AI AssistView(SfAIAssistView).
<local:CustomAssistView x:Name="assistView" Grid.Row="1" ShowHeader="{Binding ShowHeader}"
ItemCopyCommand="{Binding CopyCommand}"
RequestCommand="{Binding AssistViewRequestCommand}"
ItemRetryCommand="{Binding RetryCommand}"
HeaderTemplate="{StaticResource headerTemplate}" AssistItems="{Binding AssistItems}">
<local:CustomAssistView.ControlTemplate>
<ControlTemplate>
<ContentView>
<ContentView.Content>
<Grid>
<ContentView IsVisible="{Binding IsActiveChatView}" Content="{TemplateBinding AssistChatView}" BindingContext="{TemplateBinding BindingContext}" />
<local:ComposeView IsVisible="{Binding IsActiveComposeView}" BindingContext="{TemplateBinding BindingContext}"/>
<ActivityIndicator x:Name="Indicator" IsRunning="{Binding ShowIndicator}" BindingContext="{TemplateBinding BindingContext}"
VerticalOptions="Center"
HorizontalOptions="Center"
/>
</Grid>
</ContentView.Content>
</ContentView>
</ControlTemplate>
</local:CustomAssistView.ControlTemplate>
</local:CustomAssistView>
CustomAssistViewChat :
public class CustomAssistViewChat : AssistViewChat
{
public CustomAssistViewChat(Syncfusion.Maui.AIAssistView.SfAIAssistView aIAssistView) : base(aIAssistView)
{
}
}
public class CustomAssistView : Syncfusion.Maui.AIAssistView.SfAIAssistView
{
public static readonly BindableProperty AssistChatViewProperty =
BindableProperty.Create(nameof(AssistChatView), typeof(CustomAssistViewChat), typeof(CustomAssistView));
public CustomAssistViewChat AssistChatView
{
get { return (CustomAssistViewChat)this.GetValue(AssistChatViewProperty); }
set { this.SetValue(AssistChatViewProperty, value); }
}
protected override AssistViewChat CreateAssistChat()
{
AssistChatView = new CustomAssistViewChat(this);
return AssistChatView;
}
}
To run the demo, refer to System Requirements for .NET MAUI
If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.
Syncfusion® has no liability for any damage or consequence that may arise from using or viewing the samples. The samples are for demonstrative purposes. If you choose to use or access the samples, you agree to not hold Syncfusion® liable, in any form, for any damage related to use, for accessing, or viewing the samples. By accessing, viewing, or seeing the samples, you acknowledge and agree Syncfusion®'s samples will not allow you seek injunctive relief in any form for any claim related to the sample. If you do not agree to this, do not view, access, utilize, or otherwise do anything with Syncfusion®'s samples.