Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the following code to drop the dynamic ellipse in listview... the event mousMove is working but the object not appearing in the dropped position, still there in old position.. I am looking to drag and drop in the same listview. tlist is the observableCollection

private void listview_Drop(object sender, DragEventArgs e) {

Ellipse droppedData = e.Data.GetData(typeof(Ellipse)) as Ellipse;
Ellipse target = ((ListViewItem)(sender)).DataContext as Ellipse;

int removedIdx = listview.Items.IndexOf(droppedData);
int targetIdx = listview.Items.IndexOf(target);

if (removedIdx < targetIdx)
{
tlist.Insert(targetIdx + 1, droppedData);
tlist.RemoveAt(removedIdx);
}
else
{
int remIdx = removedIdx + 1;
if (tlist.Count + 1 > remIdx)
{
tlist.Insert(targetIdx, droppedData);
tlist.RemoveAt(remIdx);
}
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900