I have a list box that contains a list of WorkItems (from TFS). I want to add items to be selected, but it is failing to identify the items as the same.
Here is my code
public void SelectQueryResultItem(WorkItem item)
{
lstQueryResults.SelectedItems.Add(item);
}
This works great when the WorkItem passed in is from the same query that is in the SelectedItems list. However if it came from a different query (ie the object reference is not the same) then it does not identify the object correctly.
I assume it is comparing on reference. I want to override that and make it compare on item.Id. Is there a way to do that?
Note that I am using the WPF ListBox, not the WinForms ListBox