Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an Drag/Drop Cancelled Event in WinRT?

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?

like image 494
Lars Düwel Avatar asked Nov 29 '25 04:11

Lars Düwel


1 Answers

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;
        // ...
    }
like image 74
HCL Avatar answered Nov 30 '25 18:11

HCL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!