WPF: Getting, sorting and filtering information in pure XAML (well almost)

.NET, Technical stuff, WPF
See comments

One question on the WPF forum caught my attention. It was a nice challenge, so I decided to give it a try. It turned out not bad, so I thought I would post it on my website for future reference. The question is: How to display all the cultures in a ListBox, and filter to display only these starting with “en-“. Good news is: you can do a lot of that in XAML only. Bad news is: If you want to filter, you need code-behind.

I posted a comprehensive example on my website’s articles section. It shows how to initialize an ObjectDataProvider using the static method CultureInfo.GetCultures. Since this method needs a parameter, I also show how to pass the right value to the method.

Then I show how to use CollectionViewSource to sort and group a view of that list in pure XAML. Finally, I show how to filter the list using the same CollectionViewSource and an event handler in code behind.

Previous entry | Next blog entry

Comments for WPF: Getting, sorting and filtering information in pure XAML (well almost)