Drag WPF Popup control

前端 未结 6 1057
死守一世寂寞
死守一世寂寞 2020-12-13 14:32

the WPF Popup control is nice, but somewhat limited in my opinion. is there a way to \"drag\" a popup around when it is opened (like with the DragMove() method of windows)?<

6条回答
  •  失恋的感觉
    2020-12-13 15:16

    Another way of achieving this is to set your Popup's placement to MousePoint. This makes the popup initially appear at the position of the mouse cursor.

    Then you can either use a Thumb or MouseMove event to set the Popup's HorizontalOffset & VerticalOffset. These properties shift the Popup away from its original position as the user drags it.

    Remember to reset HorizontalOffset and VerticalOffset back to zero for the next use of the popup!

提交回复
热议问题