O'Reilly logo

Windows Presentation Foundation 4.5 Cookbook by Pavel Yosifovich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sorting and filtering bound collections

Data templates provide a powerful way to present data using text, images, and anything else WPF is capable of. Often, we need to present the data in some order, typically sorted by some property (or properties). Sometimes we don't want to show all data, but a part of it, such as when a user searches for something and we want to show the result of the search, which maybe just a subset of the original data.

One way to go about it is to operate on the data itself. We can certainly apply sorting on lists (List<T>.Sort, Array.Sort, and so on), as well as filtering (List<T>.FindAll), and by using Language Integrated Query (LINQ) it's even easier (and more versatile) to sort (orderby clause) and/or filter (where ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required