Drag WPF Popup control

前端 未结 6 1059
死守一世寂寞
死守一世寂寞 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:15

    The issue with loosing the mouse when moving too fast, could be resolved


    This is taken from msdn:

    The new window contains the Child content of Popup.

    The Popup control maintains a reference to its Child content as a logical child. When the new window is created, the content of Popup becomes a visual child of the window and remains the logical child of Popup. Conversely, Popup remains the logical parent of its Child content.


    In the other words, the child of the popup is displayed in standalone window.

    So when trying to the following:
    Popup.CaptureMouse() is capturing the wrapper window and not the popup itself. Instead using Popup.Child.CaptureMouse() captures the actual popup.

    And all other events should be registered using Popup.Child.

    Like Popup.Child.MouseMove, Popup.Child.LostCapture and so on

    This has been tested and works perfectly fine

提交回复
热议问题