Header Customization in .NET MAUI AI AssistView (SfAIAssistView)
26 Jun 20254 minutes to read
This section explains how to define and customize the header in the SfAIAssistView.
Show/hide header
The SfAIAssistView control allows you to display a default header by configuring the ShowHeader property. When this property is set to true
, the default header will be shown at the top of the assist view. The default value of the ShowHeader property is false
.
<syncfusion:SfAIAssistView x:Name="sfAIAssistView"
ShowHeader="True"/>
SfAIAssistView sfAIAssistView;
public MainPage()
{
InitializeComponent();
this.sfAIAssistView = new SfAIAssistView();
this.sfAIAssistView.ShowHeader = true;
this.Content = sfAIAssistView;
}
Header text
The SfAIAssistView
control allows you to customize the header text using the HeaderText property.
<syncfusion:SfAIAssistView x:Name="sfAIAssistView"
HeaderText="Ask AI"
ShowHeader="True"/>
SfAIAssistView sfAIAssistView;
public MainPage()
{
InitializeComponent();
this.sfAIAssistView = new SfAIAssistView();
this.sfAIAssistView.HeaderText = "Ask AI";
this.sfAIAssistView.ShowHeader = true;
this.Content = sfAIAssistView;
}
Header customization
The SfAIAssistView control allows you to fully customize the header’s appearance by using the HeaderTemplate property. This property lets you define a custom layout and style for the header.
<ContentPage.Resources>
<ResourceDictionary>
<DataTemplate x:Key="headerTemplate">
<Grid RowDefinitions="45,30,Auto" RowSpacing="10" Padding="0,18,0,0">
<Image Source="aiassistview.png" HorizontalOptions="Center"/>
<Label Padding="0,5,0,0" Text="Ask AI Anything!" HorizontalOptions="Center" Grid.Row="1" FontSize="16"/>
<FlexLayout x:Name="headerlayout"
BindableLayout.ItemsSource="{Binding HeaderInfoCollection}">
...
</FlexLayout>
</Grid>
</DataTemplate>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<syncfusion:SfAIAssistView x:Name="sfAIAssistView"
AssistItems="{Binding AssistItems}"
ShowHeader="True"
HeaderTemplate="{StaticResource headerTemplate}">
</syncfusion:SfAIAssistView>
</ContentPage.Content>