void Source_LayoutUpdated(object sender, EventArgs e) { Rect bounds = SourceElement.GetBounds(); Point p = TargetElement.FindClosestPoint(bounds.GetCenter()); Point[] newPoints = JunctionGeometryHelper.ComputeOptimalConnection(bounds, new Rect(p.X, p.Y, 1, 1), false); if (newPoints[0] != points[0] || newPoints[1] != points[1]) { points = newPoints; InvalidateVisual(); } }