Search code examples
c#.netwpfoopmdi

How to detect two windows near each other


I've got an MDI application, which allows users to drag and move windows around the screen. I would like to detect when two windows are near each other, but I am unsure how to go about this. I am using the WPF MDI library to handle MDI, however I am unsure whether it has this functionality built-in.

If not, what would be the standard approach to tackling this issue?

What I thought of doing is - while a window is being dragged, the X and Y co-ordinates of surrounding windows is constantly being checked, to see if they are within close proximity or not. However if I have many windows, this might end up causing some lag. Any ideas?


Solution

  • Just incase anyone looks this up later on - this is the approach which I took:

    I added a DoDragDrop event to my source window being dragged and set the other window as the drop target. It might be specific to my requirements, but the end result works perfectly!