How to get filtered ListView items after Items.Filter is set
-
Hi, I have a ListView which is bound to a list of items of type Test. The list contains items with Id= 1 to 100.
class Test { public int Id {get; set;} public string Name {get; set;} }
Now I apply a filter as follows:listView.Items.Filter = delegate( object item ) { object idValue = item.GetType().GetProperty("Id").GetValue(item, null); if ( Convert.ToInt32(idValue) > 75 ) { return true; } else { return false; } };
On applying the filter now i can view only the last 25 rows in the ListView, which is fine. Now what i want to know is there a way to directly get a list of visible rows in the listview (the filtered rows). The ItemSource property returns all 100 rows always. How can i get the visible 25 rows?Pankaj Chamria, Software Developer.
modified on Tuesday, April 14, 2009 4:20 AM
-
Hi, I have a ListView which is bound to a list of items of type Test. The list contains items with Id= 1 to 100.
class Test { public int Id {get; set;} public string Name {get; set;} }
Now I apply a filter as follows:listView.Items.Filter = delegate( object item ) { object idValue = item.GetType().GetProperty("Id").GetValue(item, null); if ( Convert.ToInt32(idValue) > 75 ) { return true; } else { return false; } };
On applying the filter now i can view only the last 25 rows in the ListView, which is fine. Now what i want to know is there a way to directly get a list of visible rows in the listview (the filtered rows). The ItemSource property returns all 100 rows always. How can i get the visible 25 rows?Pankaj Chamria, Software Developer.
modified on Tuesday, April 14, 2009 4:20 AM
You could keep track of the filtered items yourself, i.e. put items in a list whenever your filter is going to return True.
Blog: http://windowsclientdevelopment.spaces.live.com FAQs: http://windowspresentationfoundation.wikispaces.com http://windowsmobile.wikispaces.com http://vsto.wikispaces.com