1
Vote

Crash on reordering simple array or List<string>

description

Try to use following source items and reorder them:
listControl.ItemsSource = new List<string>(new[] { "a", "b", "c", "d" });
Or
listControl.ItemsSource = new[] { "a", "b", "c", "d" };
What you will see, is a FileNotFoundException thrown inside ReorderListBox::MoveItem() method, on a try of sourceList manipulation. There should be more custom behaviors allowed and more checks applied.

What about:
  • if the collection implements some "custom interface" - call a methods from it, to move the item
  • respect IsReadOnly=true property of IList, by ignoring call to MoveItem() method
  • respect IsFixedSize=true property of IList, by using Array manipulation methods to place new item in respective place
  • if INotifyCollectionChanged is not implemented - refresh the UI in code as array/list is actually updated correctly
Cheers,
Pawel Hofman

comments