How to notify the selection changed in WinUI SfComboBox?
In this article, WinUI ComboBox can get the notification of the selection change using the event SelectionChanged. This event contains the newly selected and removed items in the AddedItems and RemovedItems properties. Let’s look at the property details.
- AddedItems - Contains the items that were selected.
- RemovedItems - Contains the items that were unselected.
XAML:
<editors:SfComboBox x:Name="comboBox"
Width="250"
TextMemberPath="Name"
DisplayMemberPath="Name"
ItemsSource="{Binding SocialMedias}"
SelectionChanged="OnComboBoxSelectionChanged" />
The SelectionChanged event can be handled as follows.
C#
private async void OnComboBoxSelectionChanged(object sender, ComboBoxSelectionChangedEventArgs e)
{
var cd = new ContentDialog
{
Content = "Selected item was changed.",
CloseButtonText = "Close"
};
cd.XamlRoot = this.Content.XamlRoot;
var result = await cd.ShowAsync();
}
Conclusion
I hope you enjoyed learning about how to notify the selection changed in WinUI SfComboBox.
You can refer to our WinUI ComboBox feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the Licence and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forum, Support portal, or feedback portal. We are always happy to assist you!