private void ListBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ListBox parent = sender as ListBox; BandStrapp data = GetObjectDataFromPoint(parent, e.GetPosition(parent)) as BandStrapp; if (data != null) { DragDrop.DoDragDrop(parent, data, DragDropEffects.Move); } }
// Drag & Drop care of http://stackoverflow.com/a/4004590 private void ListBox_Drop(object sender, DragEventArgs e) { ListBox parent = sender as ListBox; BandStrapp data = e.Data.GetData(typeof(BandStrapp)) as BandStrapp; BandStrapp objectToPlaceBefore = GetObjectDataFromPoint(parent, e.GetPosition(parent)) as BandStrapp; if (data != null && objectToPlaceBefore != null) { int index = _band.Tiles.Strip.IndexOf(objectToPlaceBefore); _band.Tiles.Strip.Remove(data); _band.Tiles.Strip.Insert(index, data); parent.SelectedItem = data; } }