Drag WPF Popup control

前端 未结 6 1068
死守一世寂寞
死守一世寂寞 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条回答
  •  旧时难觅i
    2020-12-13 15:14

    There is no DragMove for PopUp. Just a small work around, there is lot of improvements you can add to this.

    
                   
    
    

    In the code behind , add this mousemove event

       pop.MouseMove += new MouseEventHandler(pop_MouseMove);
    
       void pop_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                pop.PlacementRectangle = new Rect(new Point(e.GetPosition(this).X,
                    e.GetPosition(this).Y),new Point(200,200));
    
            }
        }
    

提交回复
热议问题