We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback
Platform : WPF
Category : ItemsControl

How do I filter out duplicate entries in my list when bound to a data source?

The fact that you have duplicate entries probably suggests that you are binding to the wrong data source. But, in any case, there are possibly valid scenarios where this is necessary. Here is a solution.

One way is to group the list by name using CollectionViewSource and then bind the Groups to the ListBox. Here is some code:

(for better code formatting, look at this thread: Distinct Value Filter For ListBox

If you Contracts collection is like this: Then you can use the CollectionViewSource to bind to it and group the colelction by Name as follows: This will render the listbox the way you want - ignoring the duplicate names. You can then interpret the selected item as follows:

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon