tags:

views:

387

answers:

1

I have created a custom window set to windowStyle="none", (no title or maximize - minimize buttons) and i am trying to implement a DragMove operation when the user clicks and drags on a grid. (by using DragMove on a MouseLeftButtonDown Handler)

First weird issue that this event nevers gets fired if the grid has no backround. Adding some background color does make the event to get fired, but after the first drag i get this error:

"Can only call DragMove when primary mouse button is down"

Code Snipet:

Private Sub Grid1_MouseLeftButtonDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Grid1.MouseLeftButtonDown
    DragMove()
End Sub

I know that this would work fine for a label, but isnt there a way to make it work for a grid?

A: 

OK, I found the answer..

I used a border to wrap the grid and then caught the Border1_MouseLeftButtonDown event.

I also had to set the borders Background to "Transparent", and now everything works like a charm.

Private Sub Border1_MouseLeftButtonDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Border1.MouseLeftButtonDown
    DragMove()
End Sub
Entrodus