views:

388

answers:

1

This is a (kind of) similar situation as in the SDK Sample Shopping Cart for MS Surface.

I have an application with two ScatterViews. The first covers the complete Surface window ('surface'). The second resides in a TagVisualization object ('pod'). There might be more than one pod available (if more than one tag is down on the table).

I would like to be able to drag a ScatterViewItem from the 'pod' to the 'surface' or another 'pod'. I have no problems in detecting if a ScatterViewItem is leaving its ScatterView parent. Also, no problems in reparenting the ScatterViewItem.

However, I want to detect which ScatterView the item is being dragged on. In the SDK Sample they have used a visual element (an ellipse in this case) which is below the ScatterViews. VisualTreeHelper.HitTest is used to determine if the contact is over the ellipse. If so, the 'connected' ScatterView is found.

I don't think this is a very elegant solution. I wouldn't want a visual element put in there, just to detect if a contact is over a ScatterView.

Are there betterwways to accomplish this kind of 'hittesting'?

Thanks, Bart

+1  A: 

Well, first of all, I have a hunch that drag&drop is going to get a lot easier with Surface soon, so I wouldn't spend too much time fretting over an additonal element.

But treating this more as a general question - You wouldn't necessarily have to add a visual element just to do the hittest, but hittesting is still going to be the best way to determine if there is a particular element at a given point.

The sample you're talking didn't just add the ellipse for hittesting, it was also serving as the background of the 'pod'. So they only wanted to handle the drop when the contact was over that ellipse, because that ellipse defined the boundaries. Another route might be to set the background of your scatterview, and do the hittest against that control. Then, if you wanted to change the boundaries of the 'pod' to something other than a rectangle, you'd want to apply a clipping path to the scatterview.

Ben Reierson
I did the background thingy and it did work, but it's not elegant. But in the timeframe for this project, it had to do. Thanks
Bart Roozendaal