(X) Hide this
    • Login
    • Join
      • Say No Bots Generate New Image
        By clicking 'Register' you accept the terms of use .

Filtering collections from XAML using CollectionViewSource

(0 votes)
0 comments   /   posted by Silverlight Show on Apr 13, 2012
Tags:   windows-phone , nico-vermeir

Read the original article by Nico Vermeir at Nico's Blog

I find that I often run into the need of separating a collection of items into several collections just so I can bind them to multiple listboxes, for example a list of sessions spanning several tracks and each track is shown in his own listbox in a pivotitem. To get this done you can start by adding multiple collections to your viewmodel and divide the items there. However this makes your viewmodel very big in a very short time. A better way to do this is using CollectionViewSource items in XAML. Let me show you how.

First thing I did was building a demo class existing out of a title and a description, these two properties will be shown in the listbox later on. A third property is the one we’ll use to filter the data, here’s the completed class.


No comments

Add Comment

Login to comment:
  *      *       

Our News on Twitter