Example #1
0
        /// <summary>
        /// Decides whether the specified framework elements intersect within a canvas.
        /// </summary>
        /// <param name="first">The first framework element.</param>
        /// <param name="second">The second framework element.</param>
        /// <returns>True if the elements intersect. False otherwise.</returns>
        public static bool IntersectsWith(this FrameworkElement first, FrameworkElement second)
        {
            Rect p1 = first.Position();
            Rect p2 = second.Position();

            return (p1.Y + p1.Height < p2.Y) || (p1.Y > p2.Y + p2.Height) || (p1.X + p1.Width < p2.X) || (p1.X > p2.X + p2.Width);
        }