C# 捕捉/粘性 WPF 窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1028024/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Snapping / Sticky WPF Windows
提问by Andrija
I'm looking for solution to add snapping/sticky windows functionallity (winamp-like) to existing WPF application. Same thing as it was asked here, just I need it for WPF.
我正在寻找将捕捉/粘性窗口功能(类似 winamp)添加到现有 WPF 应用程序的解决方案。与此处要求的相同,只是我需要它用于 WPF。
It doesn't have to have docking function, just to snap to border of other windows inside same application and edge of screen (including taskbar) if possible. Preferably open source solution.
它不必具有停靠功能,只要可能的话,只需捕捉到同一应用程序内其他窗口的边框和屏幕边缘(包括任务栏)。最好是开源解决方案。
Thanks
谢谢
采纳答案by Ricibald
Here my project that make your wpf app snapping / sticky. It works great:
这是我的项目,使您的 wpf 应用程序捕捉/粘性。它工作得很好:
http://programminghacks.net/2009/10/19/download-snapping-sticky-magnetic-windows-for-wpf/
http://programminghacks.net/2009/10/19/download-snapping-sticky-magnetic-windows-for-wpf/
回答by ravuya
The WPF Docking Librarymay provide some of what you are looking for, but I'm unsure if it works on the entire screen or just on your application window.
在WPF对接图书馆可以提供一些你在找什么,但我不能确定它是否工作在整个屏幕上,或只是在你的应用程序窗口。
回答by m1k4
HuddledMasses.org has very nice example for snapping to screen edges (nice opensource framework underneath also)
HuddledMasses.org 有很好的捕捉屏幕边缘的例子(下面也有很好的开源框架)
HuddledMasses - WPF windows that snap to screen edges
HuddledMasses - 捕捉到屏幕边缘的 WPF 窗口
However, it lacks snapping to other windows. There is another solution on CodeProject. It's Windows Forms sticky windows. There you can find implementation for nearest window detection and snapping, which you/me/orsomebodyelse should implement in WPF manner.
但是,它缺乏与其他窗口的对齐。CodeProject 上还有另一个解决方案。它是 Windows 窗体粘滞窗口。在那里你可以找到最近窗口检测和捕捉的实现,你/我/其他人应该以 WPF 方式实现。
Edit: I've created solution based on the text above
编辑:我已经根据上面的文字创建了解决方案