Loading...
Loading...
Implement Syncfusion WPF SfAIAssistView for AI chat and conversational assistant interfaces. Use this when building AI assistant UIs, message threads with AI responses, or integrating OpenAI/SemanticKernel in WPF. Covers typing indicators, suggestions, input/response toolbars, stop-responding features, and PromptRequest events using Syncfusion.SfChat.Wpf.
npx skill4agent add syncfusion/wpf-ui-components-skills syncfusion-wpf-ai-assistviewPromptRequestViewTemplateSelectorSyncfusion.SfChat.WpfSyncfusion.UI.Xaml.ChatSfAIAssistViewTextMessageAIMessageAuthorTypingIndicator<!-- MainWindow.xaml -->
<Window xmlns:syncfusion="clr-namespace:Syncfusion.UI.Xaml.Chat;assembly=Syncfusion.SfChat.WPF">
<Grid>
<Grid.DataContext>
<local:ViewModel/>
</Grid.DataContext>
<syncfusion:SfAIAssistView
Messages="{Binding Chats}"
CurrentUser="{Binding CurrentUser}"
Suggestions="{Binding Suggestions}"
ShowTypingIndicator="{Binding ShowTypingIndicator}"
TypingIndicator="{Binding TypingIndicator}" />
</Grid>
</Window>// ViewModel.cs
public class ViewModel : INotifyPropertyChanged
{
public ObservableCollection<object> Chats { get; set; }
public Author CurrentUser { get; set; }
public ViewModel()
{
Chats = new ObservableCollection<object>();
CurrentUser = new Author { Name = "User" };
Chats.Add(new TextMessage
{
Author = CurrentUser,
Text = "Hello, how can you help me?"
});
Chats.Add(new TextMessage
{
Author = new Author { Name = "AI" },
Text = "I can answer questions and help with tasks."
});
}
}ObservableCollection<object>TextMessageAuthorCurrentUserMicrosoft.SemanticKernelIChatCompletionServiceKernelAIAssistChatServiceCollectionChangedAIMessageContentTemplateViewTemplateSelectorShowTypingIndicatorSuggestionsIEnumerable<string>TypingIndicatorShowTypingIndicatorIsInputToolbarVisibleInputToolbarPositionInputToolbarItemInputToolbarItemClickedInputToolbarHeaderTemplateIsResponseToolbarVisibleResponseToolbarItemIndexItemTypeItemTemplateResponseToolbarItemClickedPromptRequestPromptRequestEventArgsInputMessageHandledEnableStopRespondingStopRespondingStopRespondingCommandStopRespondingTemplate| Property | Type | Purpose |
|---|---|---|
| | Chat message collection |
| | Identifies the local user |
| | Suggestion chips shown after AI response |
| | Shows/hides typing animation |
| | Typing indicator with Author |
| | Shows custom input toolbar (default: false) |
| | Shows response toolbar (default: true) |
| | Enables Stop Responding button (default: false) |
| | Custom rendering per message type |
// Subscribe to CollectionChanged on Chats
Chats.CollectionChanged += async (s, e) =>
{
if (e.Action == NotifyCollectionChangedAction.Add
&& e.NewItems[0] is TextMessage msg
&& msg.Author.Name == CurrentUser.Name)
{
ShowTypingIndicator = true;
var reply = await aiService.GetResponseAsync(msg.Text);
Chats.Add(new AIMessage { Author = aiAuthor, Text = reply });
ShowTypingIndicator = false;
}
};Suggestions = new List<string> { "Tell me more", "Give an example", "Summarize" };<syncfusion:SfAIAssistView PromptRequest="OnPromptRequest" />private void OnPromptRequest(object sender, PromptRequestEventArgs e)
{
// e.InputMessage contains the user's text
e.Handled = true; // Prevent default processing
}