Sunday, 15 January 2012

c# - Change the comparer for a ListBox -


I have a list box that has a list of agenda (from TFS). I want to add items to be selected, but have failed to identify items as the same.

This is my code

  Public Zero SelectQueryResultItem (Work item) {lstQueryResults.SelectedItems.Add (item); }  

This works when the WorkItem was passed from the same query that is in the SelectedItems list. However, if it comes from a different query (i.e. the object reference is not the same) then it can not correctly identify the object

I think it is comparing the reference. I want to override it and compare it to the item. Is there any way to do this?

Note that I am using it,

Instead, have you tried to override the workmeam square to compare with the ID? This is not ideal because it is obvious that two examples with the same ID are not necessarily the same. But I'm not sure how you can convince the selector base class to use a custom iCompaimer.

Edit I dug a little deeply and found that you can get it from the collection (there is a wrap around a collection in WPF) and return a custom ICPPrier to its comparative asset Override. So you can create something like the Works Collection Weave which overrides comparative, and the worktime returns something like IP Compaipers.

Hope it helps.


No comments:

Post a Comment