views:

521

answers:

1

Hi All, I have WPF listview, with around 1000 records in it. I am doing on the fly filtering of listview items, that is as user types in to text box control, it matches items with text box content and filter items in to listview. So far filtering was working fine and it was pretty fast. Recently I have implemented custom sort on this listview, after that filtering has become very slow. Please provide me guidelines to improve performance of listview filtering without affecting sorting performance.

Regards sandeep

A: 

Just be aware the the method:

public override int Compare(object obj1, object obj2)

will be called a lot of times. Sacrifice genericism for performance. If you do an implementation that uses reflection or anything with a relatively long duration here, this will be slow.

Duncan Edwards
I added breakpoint there and checked... breakpoint is not hitting in to Compare method...
Sandeep
Then your problem has nothing to do with the custom sort. How are you implementing the sorting?
Duncan Edwards
Sorry, I meant "How are you implementing filtering?"
Duncan Edwards
Thanks...your first comment was right...Compare method is culprit...line were i had given breakpoint earlier was not hitting but on shifting breakpoint i could see Compare method is called for each item and each filter key.
Sandeep
Cool, can you please accept my answer? Cheers!
Duncan Edwards