I have some Rectangle object at my Canvas, and one Rect which has a Move() method. I would like to do that, if my Rect intersectWith one of the Rectangle, then that Rectangle be deleted.
Something like that (rct is a Rect, rctn is a Rectangle):
if (rct.InterSectsWith(rctn))
{
rctn.Invalidate();
}
What shoud i do?
I would suggest using the Rect's native IntersectsWith function and just create a new Rect From your Rectangle object.
rct.IntersectsWith(new Rect(rctn.Margin.Left, rctn.Margin.Top, rctn.Width, rctn.Height));
This assumes that rctn is a direct child of Canvas, and that it is positioned left and top. If it isn't, you can use the TranslatePoint function described in this question to get the x and y coordinates relative to your Canvas.