Reputation: 127
im looking for an Drag/Drop cancelled event in Metro, this means if the user drags an item and drops it outside of an droppable area.
how can i achieve this or is there any workaround?
Upvotes: 3
Views: 1093
Reputation: 2976
Dude, instead of capturing pointer released on the whole page you can register "pointer capture lost" on the listview or the item that you drag, i believe it fires less times at least :D
listView_PointerCaptureLost(object sender, PointerRoutedEventArgs e){
//do the logic you want;
}
Upvotes: 0
Reputation: 36785
I have not found such an event (for c#/XAML)! Perhaps (hopefully) an event will exists in the final release!
As a temporary workaround, I have registered to the Window.Current.CoreWindow.PointerReleased
-event.
On drag start then, I set a boolean indicator to true, and if drag ends, the PointerReleased
-event will be fired and I can test for the boolean indicator.
Workaround
In the constructor of the Page (or whatever element) register to PointerReleased:
Window.Current.CoreWindow.PointerReleased+=CoreWindow_PointerReleased;
The eventhandler could look somehow like this:
void CoreWindow_PointerReleased(CoreWindow sender, PointerEventArgs args) {
if (m_isDragging) {
m_isDragging = false;
// Here you know that a drag-operation came to a end
}
}
And the indicator you can set for example as follows;
private void Entries_DragStarting(object sender, DragItemsStartingEventArgs e){
m_isDragging = true;
// ...
}
Upvotes: 5