diff --git a/wpf/AI-AssistView/Getting-Started.md b/wpf/AI-AssistView/Getting-Started.md index c7f5ef535a..e83dfbe229 100644 --- a/wpf/AI-AssistView/Getting-Started.md +++ b/wpf/AI-AssistView/Getting-Started.md @@ -1,7 +1,7 @@ --- layout: post title: Getting Started with WPF AI AssistView control | Syncfusion -description: Learn about getting started with the Syncfusion WinUI AI AssistView (SfAIAssistView) control with its basic features. +description: Learn about getting started with the Syncfusion WPF AI AssistView (SfAIAssistView) control with its basic features. platform: wpf control: AI AssistView documentation: ug @@ -9,16 +9,18 @@ documentation: ug # Getting Started with WPF AI AssistView -This section explains the steps required to add the WinUI [SfAIAssistView](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Chat.SfAIAssistView.html) control with its basic features. +This section explains the steps required to add the Wpf [SfAIAssistView](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Chat.SfAIAssistView.html) control with its basic features. -## Creating an application with WPF AI AssistView +## Structure of SfAIAssistView -1. Create a [Wpf desktop app for C# and .NET 6](https://docs.microsoft.com/en-us/windows/apps/winui/winui3/get-started-winui3-for-desktop). +![WPF SfAIAssistView Structure](aiassistview_images/wpf_aiassistview_control_structure.png) + +## Adding WPF SfAIAssistview via xaml + +1. Create a [Wpf desktop app for C# and .NET 6](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/get-started/create-app-visual-studio?view=netdesktop-9.0). 2. Add reference to [Syncfusion.SfChat.Wpf](https://www.nuget.org/packages/Syncfusion.SfChat.Wpf) NuGet. 3. Import the control namespace `Syncfusion.UI.Xaml.Chat` in XAML or C# code. -4. Initialize the [SfAIAssistView](https://help.syncfusion.com/cr/winui/Syncfusion.UI.Xaml.Chat.SfAIAssistView.html) control. - -## Initialize AI AssistView +4. Initialize the [SfAIAssistView](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Chat.SfAIAssistView.html) control. {% tabs %} {% highlight xaml %} @@ -38,42 +40,47 @@ This section explains the steps required to add the WinUI [SfAIAssistView](https -{% endhighlight %} +{% endhighlight %} +{% endtabs %} +## Adding WPF SfAIAssistview via C# + +1. Create a [Wpf desktop app for C# and .NET 6](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/get-started/create-app-visual-studio?view=netdesktop-9.0). +2. Add reference to [Syncfusion.SfChat.Wpf](https://www.nuget.org/packages/Syncfusion.SfChat.Wpf) NuGet. +3. Import the control namespace `Syncfusion.UI.Xaml.Chat` in XAML or C# code. +4. Initialize the [SfAIAssistView](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Chat.SfAIAssistView.html) control. + +{% tabs %} {% highlight C# %} -// Creating an instance of the AI AssistView control. -SfAIAssistView aiAssistView = new SfAIAssistView(); +using Syncfusion.UI.Xaml.Chat; + +namespace GettingStarted +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + this.InitializeComponent(); + // Creating an instance of the AIAssistView control + SfAIAssistView assistView = new SfAIAssistView(); + grid.Children.Add(assistView); + } + } +} {% endhighlight %} {% endtabs %} + ## Creating ViewModel for AI AssistView Create a simple chat collection as shown in the following code example in a new class file. Save it as ViewModel.cs file. {% tabs %} - -{% highlight xaml %} - - - - - - - -{% endhighlight %} - {% highlight C# %} public class ViewModel : INotifyPropertyChanged @@ -89,9 +96,9 @@ Create a simple chat collection as shown in the following code example in a new private async void GenerateMessages() { - this.Chats.Add( new TextMessage { Author = CurrentUser, Text = "What is WinUI?" } ); + this.Chats.Add( new TextMessage { Author = CurrentUser, Text = "What is WPF?" } ); await Task.Delay(1000); - this.Chats.Add( new TextMessage { Author = new Author { Name = "Bot" }, Text = "WinUI is a user interface layer that contains modern controls and styles for building Windows apps." }); + this.Chats.Add( new TextMessage { Author = new Author { Name = "Bot" }, Text = "WPF is a user interface layer that contains modern controls and styles for building Windows apps." }); } public ObservableCollection Chats @@ -136,4 +143,34 @@ Create a simple chat collection as shown in the following code example in a new {% endhighlight %} {% endtabs %} +## Bind Messages + +Set the ViewModel as the DataContext for the AI AssistView or the parent window. This allows data binding between the UI and the ViewModel properties. +To populate AI AssistView, bind the chats in ViewModel to Messages property of AI AssistView. + +{% tabs %} +{% highlight xaml %} + + + + + + + + + + +{% endhighlight %} +{% endtabs %} + ![WPF AI AssistView control getting started](aiassistview_images/wpf_aiassistview_gettingstarted.png) diff --git a/wpf/AI-AssistView/Open-AI.md b/wpf/AI-AssistView/Open-AI.md index 536878eb1e..4702e700b5 100644 --- a/wpf/AI-AssistView/Open-AI.md +++ b/wpf/AI-AssistView/Open-AI.md @@ -13,8 +13,11 @@ This section explains about how to connect the AI AssistView with OpenAI. ## Creating an application with NuGet reference. -1. Create a [WPF desktop app for C# and .NET 6](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/getting-started/?view=netframeworkdesktop-4.8). -2. Add reference to [Microsoft Semantic NuGet](https://www.nuget.org/packages/Microsoft.SemanticKernel) NuGet. +1. Create a [Wpf desktop app for C# and .NET 6](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/get-started/create-app-visual-studio?view=netdesktop-9.0). +2. Add reference to [Syncfusion.SfChat.Wpf](https://www.nuget.org/packages/Syncfusion.SfChat.Wpf) NuGet. +3. Import the control namespace `Syncfusion.UI.Xaml.Chat` in XAML or C# code. +4. Initialize the [SfAIAssistView](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Chat.SfAIAssistView.html) control. +5. Add reference to [Microsoft Semantic NuGet](https://www.nuget.org/packages/Microsoft.SemanticKernel) NuGet. ## Creating the OpenAI view model class. @@ -24,30 +27,6 @@ To connect with OpenAI, we need the following details. * API_ENDPOINT: A string variable representing the URL endpoint of the OpenAI API. {% tabs %} - -{% highlight xaml %} - - - - - - - -{% endhighlight %} - {% highlight C# %} public class ViewModel : INotifyPropertyChanged @@ -197,4 +176,36 @@ To connect with OpenAI, we need the following details. {% endhighlight %} {% endtabs %} +## Bind Messages + +Set the ViewModel as the DataContext for the AI AssistView or the parent window. This allows data binding between the UI and the ViewModel properties. + +{% tabs %} +{% highlight xaml %} + + + + + + + + + + +{% endhighlight %} +{% endtabs %} + ![WPF AI AssistView control open ai](aiassistview_images/wpf_aiassistview_openai.gif) \ No newline at end of file diff --git a/wpf/AI-AssistView/Suggestions.md b/wpf/AI-AssistView/Suggestions.md index 68a337907b..8d6b6bd671 100644 --- a/wpf/AI-AssistView/Suggestions.md +++ b/wpf/AI-AssistView/Suggestions.md @@ -11,29 +11,11 @@ documentation: ug By using the [Suggestions](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Chat.SfAIAssistView.html#Syncfusion_UI_Xaml_Chat_SfAIAssistView_Suggestions) property, the AssistView displays AI-driven suggestions in the bottom right corner, making it easy for users to quickly respond or choose from relevant options. -{% tabs %} +## Create a ViewModel class with suggestion property -{% highlight xaml %} - - - - - - - -{% endhighlight %} +Create a simple suggestion collection as shown in the following code example in a new class file. Save it as ViewModel.cs file. +{% tabs %} {% highlight C# %} public class ViewModel : INotifyPropertyChanged @@ -114,4 +96,33 @@ By using the [Suggestions](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml {% endhighlight %} {% endtabs %} + +## Bind the Suggestion + +{% tabs %} +{% highlight xaml %} + + + + + + + + + + +{% endhighlight %} +{% endtabs %} + ![WPF AI AssistView control suggestion](aiassistview_images/wpf_aiassistview_suggestions.png) \ No newline at end of file diff --git a/wpf/AI-AssistView/Typing-Indicator.md b/wpf/AI-AssistView/Typing-Indicator.md index b5e4d17098..0269c35b08 100644 --- a/wpf/AI-AssistView/Typing-Indicator.md +++ b/wpf/AI-AssistView/Typing-Indicator.md @@ -11,31 +11,11 @@ documentation: ug By using the [TypingIndicator](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Chat.SfAIAssistView.html#Syncfusion_UI_Xaml_Chat_SfAIAssistView_TypingIndicator) property, a typing indicator is shown while the AI is processing or generating a response, giving users real-time feedback and enhancing conversational flow -{% tabs %} +## Create a ViewModel class with TypingIndicator -{% highlight xaml %} - - - - - - - -{% endhighlight %} +Create a simple suggestion collection as shown in the following code example in a new class file. Save it as ViewModel.cs file. +{% tabs %} {% highlight C# %} public class ViewModel : INotifyPropertyChanged @@ -132,4 +112,38 @@ By using the [TypingIndicator](https://help.syncfusion.com/cr/wpf/Syncfusion.UI. {% endhighlight %} {% endtabs %} +## Bind the TypingIndicator + +Set the ViewModel as the DataContext for the AI AssistView or the parent window. This allows data binding between the UI and the ViewModel properties. +To populate AI AssistView, bind the [TypingIndicator](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Chat.SfAIAssistView.html#Syncfusion_UI_Xaml_Chat_SfAIAssistView_TypingIndicator) in ViewModel to Messages property of AI AssistView. +When the application runs, the TypingIndicator will show an animation representing the AI or user typing a message. This indicator is shown when the [ShowTypingIndicator](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Chat.SfAIAssistView.html#Syncfusion_UI_Xaml_Chat_SfAIAssistView_ShowTypingIndicator) property value as true. + +{% tabs %} +{% highlight xaml %} + + + + + + + + + + +{% endhighlight %} +{% endtabs %} + ![WPF AI AssistView control typing indicator](aiassistview_images/wpf_aiassistview_typing_indicator.gif) \ No newline at end of file diff --git a/wpf/AI-AssistView/aiassistview_images/wpf_aiassistview_control_structure.png b/wpf/AI-AssistView/aiassistview_images/wpf_aiassistview_control_structure.png new file mode 100644 index 0000000000..1b73620eb1 Binary files /dev/null and b/wpf/AI-AssistView/aiassistview_images/wpf_aiassistview_control_structure.png differ