ScatterView item drag back to LibraryContainer
-
Tuesday, May 08, 2012 9:01 AM
i can drag back item with PreviewTouchMove event,in PreviewTouchMove,my logic is bool position of touchdevice in LibraryContainer,and delete item from ScatterView,and it's work perfect
but i can't do it with drag item animation,because when animation complete,i dont know which event will be trigger.
i think if i know which event will be trigger,i can find which item back to LibraryContainer,and i just do same thing as PreviewTouchMove do.
somebody know how to solve it or there have other solution
All Replies
-
Tuesday, May 08, 2012 9:04 AMIf you can post your code I will give an eye I think there is something wrong in your logic...
Gian Paolo Santopaolo - @gsantopaolo
Founder and CTO Software Lab
softwarelab.it - digitalshopwindow.com - thedarksideof.net
Disclaimer: This post is provided "AS IS" with no warranties, and confer no rights. -
Tuesday, May 08, 2012 9:14 AM
when i drag item to LibraryContainer,this will be run
private void SurfaceWindow_PreviewMouseMove(object sender, InputEventArgs e) { if (e.Device.GetCenterPosition(scatter).Y <scatter.ActualHeight-LibraryContainer.ActualHeight) { return; } else { FrameworkElement findSource = e.OriginalSource as FrameworkElement; ScatterViewItem draggedElement = null; // Find the ScatterViewitem object that is being touched. while (draggedElement == null && findSource != null) { if ((draggedElement = findSource as ScatterViewItem) == null) { findSource = VisualTreeHelper.GetParent(findSource) as FrameworkElement; } } if (draggedElement == null) { return; } //PhotoData data = draggedElement.Content as PhotoData; // Create the cursor visual try { ContentControl cursorVisual = new ContentControl() { Content = draggedElement.DataContext, Style = FindResource("CursorStyle") as Style }; // Create a list of input devices. Add the touches that // are currently captured within the dragged element and // the current touch (if it isn't already in the list). List<InputDevice> devices = new List<InputDevice>(); devices.Add(e.Device); foreach (TouchDevice touch in draggedElement.TouchesCapturedWithin) { if (touch != e.Device) { devices.Add(touch); } } ItemsControl dragSource = ItemsControl.ItemsControlFromItemContainer(draggedElement); SurfaceDragDrop.BeginDragDrop( dragSource, // The ScatterView object that the cursor is dragged out from. draggedElement, // The ScatterViewItem object that is dragged from the drag source. cursorVisual, // The visual element of the cursor. draggedElement.DataContext, // The data attached with the cursor. devices, // The input devices that start dragging the cursor. DragDropEffects.Move); // The allowed drag-and-drop effects of this operation. // Prevents the default touch behavior from happening // and disrupting our code. e.Handled = true; // Hide the ScatterViewItem for now. We will remove it // if the DragDrop is successful. draggedElement.Visibility = Visibility.Hidden; } catch { return; } } }
and this will be run after SurfaceWindow_PreviewMouseMove
private void scatter_DragCompleted(object sender, SurfaceDragCompletedEventArgs e) { if (e.Cursor.CurrentTarget != scatter && e.Cursor.Effects == DragDropEffects.Move) { scatter.Items.Remove(e.Cursor.Data); e.Handled = true; } }
-
Thursday, May 10, 2012 6:47 AM
What do you want to do exactly ? simulate a draging back operation with animation in order that the item goes back to its initial location ?
regards
serge
Your knowledge is enhanced by that of others.
-
Thursday, May 10, 2012 7:23 AM
im doing those thing.
drag item throw to LibraryContainer.
now,drag item must with finger touch and move in to LibraryContainer.can‘t throw item to LibraryContainer.
because when item stop moving,i don't know which event be trigger.if i find that event,i just do remove item from scatterview like scatter_DragCanceled do
-
Thursday, May 10, 2012 9:58 AM
here is a demo,it can drag item to LibraryContainer with touchmove or throw,but item can scale in scatterview.any suggestion?
- Edited by slumpwu Friday, May 11, 2012 12:36 AM
-
Sunday, May 13, 2012 4:46 PM
I have download you demo but could not understand what you are trying to explain.
You do not want that sctatterview get scale ?
If that is the case then set the CanScale=False;By the way if I were you I would check the Shoping cart sample which implement the DragDropScatteview class. This class handle all for you in a better way
hope it helps
serge
Your knowledge is enhanced by that of others.
-
Tuesday, May 15, 2012 5:55 AMi want to make item can scale,but in my demo,it can't.
-
Tuesday, May 15, 2012 7:11 AM
I do not know what you are trying to do in your Preview_MouseMOve event but this is not the proper event to use because it conflig with the move event when you try to scale the scatterview.
Revome all what you have in your Prevew_MouseMove event and you will see that you can scall your scatterview.
Rething properly what you are trying to reach but that is definitlly not the right event handler to use which messing up the gesture
regards
serge
Your knowledge is enhanced by that of others.
- Proposed As Answer by Serge Calderara Tuesday, May 15, 2012 7:11 AM
-
Tuesday, May 15, 2012 9:25 AM
i think you don't look clearly my code
1、in previewmousemove event,those thing i can do:
a、scale item(i bool if in scatterview aera,previewmousemove do nothing).
b、move item.
c、Rotation item。
d、drag item back to LibraryContainer with touch and move in to LibraryContainer ,but can't throw item in to LibraryContainer,cause in previewmousemove event,throw item and when item stop.i can't find any event will be trigger so i can;t find which item delete from scatterview。
2、in my demo,those thing i can do:
a、move item.
b、Rotation item。
c、drag item back to LibraryContainer with touch and move in to LibraryContainer or throw item in to LibraryContainer.the reason i can drag and throw item is the item not really in scatterview,but just like copy a shadow scatterviewitem.the really item is visiable=none and the shadow item can trigger dragcompleted event when i throw or drag to LibraryContainer,so i can delete item from scatterview.
d、can't scale item.cause when click item,the item you can concrol just a shadow scatterviewitem,not really item in scatterview.
so,i need one solution,solve throw item problem or can't scale problem.
-
Tuesday, May 15, 2012 10:28 AM
I clearly see your code and I told you that you cannot do that in preview mouse move event which messsing up the event tunnelling process until the scatterview.
Do whateveryou want but if you want to solve your ptoblem, once again check the sample SDk with Shoping cart sample and use the DragDropScatterview class which does all you need for you.
regards
serge
Your knowledge is enhanced by that of others.
- Proposed As Answer by Serge Calderara Tuesday, May 15, 2012 10:28 AM
-
Wednesday, May 16, 2012 12:50 AMi don't know why you ask me to check Shoping cart sample,in that sample,it also can't drag back item to listbox,i think it helpless for my project.
-
Wednesday, May 16, 2012 7:39 AM
I will send you a sample when I have time.
Here is a sample I made for you you can get it from here.
HOpe this help
Thnaks to mark the as answer if ok
Your knowledge is enhanced by that of others.
- Edited by Serge Calderara Wednesday, May 16, 2012 8:08 AM
- Proposed As Answer by Serge Calderara Friday, May 18, 2012 12:22 PM
- Marked As Answer by slumpwu Tuesday, May 22, 2012 1:42 AM
-
Tuesday, May 22, 2012 1:43 AMi have look your demo yet.finally i know what your logic,the demo is very helpful for me,really tkx.
-
Monday, June 18, 2012 9:24 PM
@serge, this sample help me understand too, and usuful as i am learning
Thks
wakefun
-
Friday, March 29, 2013 7:06 AM
Hey,
sorry to digging into an old thread but can anybody supply me with the sample project to achieve this?
thanks

