locked
Snap to Object/Control feature RRS feed

  • Question

  •  Hi,

    i am doing an editor kind of project application in wpf in which i am allowing user to drag their controls (i have defined my own controls that allows user to customize their screens) to the Canvas window i.e I have toolbar and canvas area.i have placed controls in the toolbar and those controls can be dragged and dropped on the canvas.

    i am done with dragging and dropping stuff and currently looking for the feature that allows me to snap one control from the boundaries of another control while placing a control to Canvas.

    i.e. when i am placing 2nd control benith/after of the 1st one and if 2nd control is coming in same vertical/horizontal line in that case system should show floating visible line to properly place control in one line.


    Please, advice me how to do this thing.

    Thanks in advance,
    Mandar.........
    Tuesday, February 24, 2009 7:43 AM

Answers

  • You can check the bound of the element being move.
    When the position of each edge of its bound is very close to a grid line calculated by all the other elements, you modify the element's TranslateTransform so that it'll be stuck to the grid line. The grid line should appear at the same time.
    • Proposed as answer by Tao Liang Wednesday, February 25, 2009 9:29 AM
    • Marked as answer by Tao Liang Friday, February 27, 2009 1:54 AM
    Wednesday, February 25, 2009 9:28 AM