0

I'm trying to show some movable controls in silverlight. I've a grid, and dynamically I've to add some controls(I'm now trying with Thumb). And user can move those controls within the grid(in the space specified for the grid). I'm not saying about the Drag and Drop controls. Actually the controls are to move as a user press mouse left button on it and starts to drag it.

Please help. Thanks in advance.

Arnab Das
  • 3,548
  • 8
  • 31
  • 43

1 Answers1

0

What you describe is drag & drop only. You need to implement this.

  1. handle the left mouse click, mouse move & left mouse up events for each of the controls you want to allow to be moved.

  2. in the left mouse click event handler:

    • set a flag "drag_on" to True
  3. in the mouse move event handler

    • check if "drag_on" is true, if false, return.
    • if drag_on is true, then set the control position (x, y) same as the mouse position.
    • you will get the mouse position from the parameter of the event handler
  4. in the mouse up event, set drag_on to false. Also set the control position to that of mouse position.

Note:

Community
  • 1
  • 1
Sesh
  • 5,993
  • 4
  • 30
  • 39
  • I'm trying with this. But in my case the problem is that I've another control (a slider) above the Grid, in which we are to add the movable controls. So for drag-drop case when we are to drop the control the control can't find the dropping grid. Again we start to drag there comes a shadow. Can this be made invisible? – Arnab Das Feb 15 '12 at 10:10
  • I am not sure I understand. Are you trying to develop a custom slider control and is your question related to the part in the slider that users will select and move? – Sesh Feb 15 '12 at 17:44