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:
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?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们可以编写一个行为来使任何
Popup
可拖动。以下是与文本框关联的弹出窗口的一些示例 XAML,当文本框获得焦点时,该文本框将打开并保持打开状态:以下是允许我们拖动
弹出窗口
的行为:如果您不熟悉行为,安装 Expression Blend 4 SDK 并添加此命名空间:
并将
System.Windows.Interactivity
添加到您的项目中。We can write a behavior to make any
Popup
draggable. Here is some sample XAML of a popup associated with a textbox that opens and stays open when the text box is focused:Here is the behavior that allows us to drag the
Popup
:If you are not familiar with behaviors, install the Expression Blend 4 SDK and add this namespaces:
and add
System.Windows.Interactivity
to your project.您可以打开具有自定义边框布局的子窗口。然后添加一个支持拖动的 MouseDown 处理程序:
在后面的代码中:
You could open a child Window with a custom border layout. Then add a MouseDown handler that enables the dragging:
In code behind: