How can i check if 2 controls overlap eachother on a canvas in WPF?

Eli Perpinyal picture Eli Perpinyal · Oct 12, 2009 · Viewed 12.3k times · Source

I am writing a designer that enables the user to drag controls around the screen. What would be the best way of detecting if a control is overlapping another control while i am dragging the one control around?

Should i just get the dimensions of the FrameworkElement and keep on checking the dimensions of the other elements?

Thanks. Eli

Answer

Thomas Levesque picture Thomas Levesque · Oct 12, 2009

You can use the Rect.IntersectsWith method