Class SfAIAssistView
A user interface control that can create modern conversational chatbot experiences in mobile applications. It is a flexible control that shows a conversation between two or more users in a fully customizable layout.
Inheritance
Namespace: Syncfusion.UI.Xaml.Chat
Assembly: Syncfusion.Chat.WinUI.dll
Syntax
public class SfAIAssistView : Control
Constructors
SfAIAssistView()
Initializes a new instance of the SfAIAssistView class.
Declaration
public SfAIAssistView()
Fields
BannerTemplateProperty
Identifies the BannerTemplate dependency property."/>
Declaration
public static readonly DependencyProperty BannerTemplateProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
CurrentUserProperty
Identifies the CurrentUser dependency property.
Declaration
public static readonly DependencyProperty CurrentUserProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
EditTemplateSelectorProperty
Identifies the EditTemplateSelector dependency property.
Declaration
public static readonly DependencyProperty EditTemplateSelectorProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
EnableStopRespondingProperty
Identifies the EnableStopResponding dependency property.
Declaration
public static readonly DependencyProperty EnableStopRespondingProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
InputToolbarItemsProperty
Identifies the InputToolbarItems dependency property.
Declaration
public static readonly DependencyProperty InputToolbarItemsProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
InputToolbarPositionProperty
Identifies the InputToolbarPositionProperty dependency property.
Declaration
public static readonly DependencyProperty InputToolbarPositionProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
IsInputToolbarVisibleProperty
Identifies the IsInputToolbarVisible dependency property.
Declaration
public static readonly DependencyProperty IsInputToolbarVisibleProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
IsResponseToolbarVisibleProperty
Identifies the IsResponseToolbarVisible dependency property.
Declaration
public static readonly DependencyProperty IsResponseToolbarVisibleProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
MessagesProperty
Identifies the Messages dependency property.
Declaration
public static readonly DependencyProperty MessagesProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
ResponseToolbarItemsProperty
Identifies the ResponseToolbarItems dependency property.
Declaration
public static readonly DependencyProperty ResponseToolbarItemsProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
ShowTypingIndicatorProperty
Identifies the ShowTypingIndicator dependency property.
Declaration
public static readonly DependencyProperty ShowTypingIndicatorProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
StopRespondingCommandProperty
Identifies the StopRespondingCommand dependency property.
Declaration
public static readonly DependencyProperty StopRespondingCommandProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
StopRespondingTemplateProperty
Identifies the StopRespondingTemplate dependency property.
Declaration
public static readonly DependencyProperty StopRespondingTemplateProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
SuggestionsProperty
Identifies the Suggestions dependency property.
Declaration
public static readonly DependencyProperty SuggestionsProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
TypingIndicatorProperty
Identifies the TypingIndicator dependency property.
Declaration
public static readonly DependencyProperty TypingIndicatorProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
ViewTemplateSelectorProperty
Gets or sets the template selector for the view mode.
Declaration
public static readonly DependencyProperty ViewTemplateSelectorProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
Properties
BannerTemplate
Gets or sets the template for the banner content in the chat control.
Declaration
public DataTemplate BannerTemplate { get; set; }
Property Value
Type |
---|
Microsoft.UI.Xaml.DataTemplate |
CurrentUser
Gets or sets the current author of a message.
Declaration
public Author CurrentUser { get; set; }
Property Value
Type |
---|
Author |
EditTemplateSelector
Gets or sets the template selector for the edit mode.
Declaration
public DataTemplateSelector EditTemplateSelector { get; set; }
Property Value
Type |
---|
Microsoft.UI.Xaml.Controls.DataTemplateSelector |
EnableStopResponding
Gets or sets a value indicating whether the "Stop Responding" option is enabled or disabled.
true
, users can manually stop the AI response using the stop responding button.
When set to false
, the option is disabled, preventing users from interrupting the response.
The default value is false
.
<syncfusion:SfAIAssistView EnableStopResponding="True"/>
Declaration
public bool EnableStopResponding { get; set; }
Property Value
Type |
---|
System.Boolean |
InputToolbarItems
Gets or sets the collection of input toolbar items.
Declaration
public ObservableCollection<InputToolbarItem> InputToolbarItems { get; set; }
Property Value
Type |
---|
System.Collections.ObjectModel.ObservableCollection<InputToolbarItem> |
Remarks
This property allows you to customize the toolbar actions available for input text area.
By You can add custom toolbar items to this collection.
Example:
// Add a custom toolbar item
myAssistView.InputToolbarItems.Add(new InputToolbarItem
{
Icon = "C:/Pictures/attachment.png",
Tooltip = "upload",
IsEnabled = true,
Visible = true
});
InputToolbarPosition
Gets or sets the position of the input textbox toolbar in the SfAIAssistView control.
Declaration
public ToolbarPosition InputToolbarPosition { get; set; }
Property Value
Type |
---|
ToolbarPosition |
IsInputToolbarVisible
Gets or sets a value indicating whether the input textbox toolbar is visible in the SfAIAssistView control.
Declaration
public bool IsInputToolbarVisible { get; set; }
Property Value
Type |
---|
System.Boolean |
IsResponseToolbarVisible
Gets or sets a value indicating whether the response toolbar is visible in the SfAIAssistView control.
Declaration
public bool IsResponseToolbarVisible { get; set; }
Property Value
Type |
---|
System.Boolean |
Messages
Gets or sets the collection of messages to be displayed in the chat.
Declaration
public object Messages { get; set; }
Property Value
Type |
---|
System.Object |
ResponseToolbarItems
Gets or sets the collection of response toolbar items.
Declaration
public ObservableCollection<ResponseToolbarItem> ResponseToolbarItems { get; set; }
Property Value
Type |
---|
System.Collections.ObjectModel.ObservableCollection<ResponseToolbarItem> |
Remarks
This property allows you to customize the toolbar actions available for response messages (AI messages).
By default, the collection includes "Copy", "Regenerate", "Like", and "Dislike" toolbar items. You can add custom toolbar items to this collection.
Example:
// Add a custom toolbar item
myAssistView.ResponseToolbarItems.Add(new ResponseToolbarItem
{
Text = "Summarize",
Tooltip = "Summarize response",
IsEnabled = true,
Visible = true
});
// Handle the toolbar item click event
myAssistView.ResponseToolbarItemClicked += (sender, args) =>
{
if (args.Item.Text == "Summarize")
{
// Handle custom action
}
};
ShowTypingIndicator
Gets or sets a value indicating whether the typing indicator should be displayed at the bottom of the chat control to notify when a user is typing.
Declaration
public bool ShowTypingIndicator { get; set; }
Property Value
Type |
---|
System.Boolean |
StopRespondingCommand
Gets or sets the command to be executed when the Stop Responding view is clicked.
Declaration
public ICommand StopRespondingCommand { get; set; }
Property Value
Type |
---|
System.Windows.Input.ICommand |
Remarks
This command allows handling user interactions when they choose to stop an ongoing response. It can be bound to a command in the ViewModel to execute specific logic.
Examples
<syncfusion:SfAIAssistView StopRespondingCommand="{Binding StopCommand}" />
StopRespondingTemplate
Gets or sets the template used to define the Stop Responding view of the SfAIAssistView.
<syncfusion:SfAIAssistView>
<syncfusion:SfAIAssistView.StopRespondingTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Stopping..." />
</StackPanel>
</DataTemplate>
</syncfusion:SfAIAssistView.StopRespondingTemplate>
</syncfusion:SfAIAssistView>
Declaration
public DataTemplate StopRespondingTemplate { get; set; }
Property Value
Type |
---|
Microsoft.UI.Xaml.DataTemplate |
Suggestions
Gets or sets the list of items to be displayed as a response to a user message. The suggestions will be displayed above the message typing/input area as part of the footer view.
Declaration
public IEnumerable<string> Suggestions { get; set; }
Property Value
Type |
---|
System.Collections.Generic.IEnumerable<System.String> |
TypingIndicator
Gets or sets the helper to set the settings for the typing indicator.
Declaration
public TypingIndicator TypingIndicator { get; set; }
Property Value
Type |
---|
TypingIndicator |
ViewTemplateSelector
Gets or sets the template selector for the view mode.
Declaration
public DataTemplateSelector ViewTemplateSelector { get; set; }
Property Value
Type |
---|
Microsoft.UI.Xaml.Controls.DataTemplateSelector |
Methods
OnApplyTemplate()
Declaration
protected override void OnApplyTemplate()
Events
InputToolbarItemClicked
Occurs when the input textbox toolbar item is clicked in the SfAIAssistView control.
Declaration
public event EventHandler<InputToolbarItemClickedEventArgs> InputToolbarItemClicked
Event Type
Type |
---|
System.EventHandler<InputToolbarItemClickedEventArgs> |
ResponseToolbarItemClicked
Occurs when a response toolbar item is clicked.
Declaration
public event EventHandler<ResponseToolbarItemClickedEventArgs> ResponseToolbarItemClicked
Event Type
Type |
---|
System.EventHandler<ResponseToolbarItemClickedEventArgs> |
StopResponding
Occurs when the stop responding view is clicked.
Declaration
public event EventHandler<EventArgs> StopResponding
Event Type
Type |
---|
System.EventHandler<System.EventArgs> |
Remarks
This event is triggered when the user interacts with the stop responding view to cancel an ongoing AI response.
Examples
SfAIAssistView aiAssistView = new SfAIAssistView();
aiAssistView.StopResponding += AiAssistView_StopResponding;
private void AiAssistView_StopResponding(object sender, EventArgs e)
{
// Handle AI response cancellation logic
MessageBox.Show("AI response has been stopped.");
}
SuggestionSelected
Occurs when the suggestion item is selected in the SfAIAssistView control.
Declaration
public event EventHandler<SuggestionClickedEventArgs> SuggestionSelected
Event Type
Type |
---|
System.EventHandler<SuggestionClickedEventArgs> |