I am working on silverlight 5.
ElementDroppingList
and ElementReceivingList
are
my two ListBox
and
a text is dropped from one to another. The problem is when i drop a text from ElementDroppingList to ElementReceivingList then it always shows 1 extra copy (dont know why). And another thing to note is the one original element (or my be the not original one)
go in sorted order and another one show at last of the ListBox.
I have used HashSet
even
then it do not avoid this extra element.
public void DropFromOneListToAnotherList(ObservableCollection<object> droppedItem) { if (droppedItem != null) { HashSet <Function> funcList = new HashSet <Function> (); foreach(object func in droppedItem) funcList.Add((Function) func); foreach(Function func in funcList.OrderBy(c => c.Label)) { ElementReceivingList.Add(func); ElementDroppingList.Remove(func); } SortListBox(); //it sorts in alphabetical order } }
Why it adds extra elemnt in ElementReceivingList on dropping (one at sorted alphabet position and one always at last)? How to avoid it ?