Reputation:
I'm using a cyclotouch screen overlay and need a drag and drop motion (i.e. finger down and move) on a listbox item to behave identically to a mouse drag and drop (i.e. click down, hold finger and move). I'm pretty desperate for help on this - I can see a lot of articles about explaining how to implement a scroll response in a wpf listbox to a touchscreen (were the items are scrolled up and down but not moved/held to the point where the finger is) but this is the opposite to what I want.
Any help seriously appreciated, I've been stuck on this for a while and I don't know a way around it.
Thanks a lot,
Dan
Upvotes: 4
Views: 2681
Reputation: 2593
I assume you are using the Surface SDK. (If not, why not?) Then this is a great resource: http://msdn.microsoft.com/en-us/library/ff727837.aspx
edit: Rereading your question I saw you used a Touch-overlay. Is it right that these do not trigger the Windows 7 touch events, but merely simulate a mouse? If so, then I'm a little curious as to why drag-and-drop with this does not work as with a regular mouse.
edit2:
So what you need to do is to add two listeners in the datatemplate; PreviewTouchDown and PreviewTouchMove.
This is what I use to start a Drag operation with mouse, but it should work with touch as well, with some modifications.
private void TreePreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
_startPoint = e.GetPosition(null);
_checkDragDrop = true;
}
private void TempTreeMouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
var mousePos = e.GetPosition(null);
var diff = _startPoint - mousePos;
if (_checkDragDrop)
{
if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
{
_checkDragDrop = false;
.
.
.
DragDropEffects val = DragDrop.DoDragDrop(DragSourceList, dragData, DragDropEffects.Move);
}
}
}
}
You probably cannot use the Telerik class with this.
Upvotes: 2