ema3272
ema3272

Reputation: 1051

How can I fire a "DragStarting" event on a button?

I am developing a "Windows Store" app. I want to be able to drag a button to set a value in a grid cell. Here is the declaration for the button:

<Button x:Name="button1"
        Grid.Column="0"
        Grid.Row="0"
        Content="1"
        HorizontalAlignment="Center"
        Click="setGUICellValue"
        CanDrag="True"
        DragStarting="dragStarting" />

And here is the code for the event handler:

        private void dragStarting(UIElement sender, DragStartingEventArgs args)
        {
            draggedBtn = (Button)sender;
        }

When I click and hold the left button of my mouse on the "button1" button and then move the mouse (i.e. when I initiate a drag of the button), the event handler does not get called. The "click" event handler gets called when I click the button and does not get called when I try to drag it.

How can I initiate the drag event?

Upvotes: 2

Views: 472

Answers (1)

Gusman
Gusman

Reputation: 15161

On store apps only controls inside a ListView or GridView can be dragged, it's a really annoying limitation.

But, you're lucky, I already created a drag page which will allow you to drag any control inside it, take a look at it: https://github.com/gusmanb/DragPage

Upvotes: 2

Related Questions