wpf 中的可拖动弹出控件 [英] A draggable popup control in wpf

查看:23
本文介绍了wpf 中的可拖动弹出控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要 wpf 中的可拖动弹出控件,想知道你们是否有任何人可以帮助我..我确实看到了以下帖子:

I need a draggable popup control in wpf and was wondering if any of your guys could help me out..I did see the following post:

拖动 WPF 弹出控件

但这不是它应该如何工作......?当我单击并拖动它时,它总是重置到特定点,而且评论者说这不是一种有效的方法......?有人有其他选择吗?

but that isnt how its supposed to work...? When i click and drag it always resets to a specific point and moreover the commenters said that this is not an efficient approach...? Does anyone have any alternatives?

谢谢!

推荐答案

您可以使用自定义边框布局打开子 Window.然后添加一个启用拖动的 MouseDown 处理程序:

You could open a child Window with a custom border layout. Then add a MouseDown handler that enables the dragging:

<Window 
        WindowStyle="None"
        ShowInTaskbar="False"
        ResizeMode="NoResize"
        SizeToContent="Height"
        MouseDown="Window_MouseDown">
...
</Window>

在代码后面:

    private void Window_MouseDown(Object sender, MouseButtonEventArgs e)
    {
        this.DragMove();
    }

这篇关于wpf 中的可拖动弹出控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆