I am upgrading a silverlight beta 2 app to RC0 and have a function that translates a point from a child element to it's parent. The purpose of the function is to ensure that an element appears exactly on top of the child even though they are not on the same canvas and don't share a parent.
Here is the current function:
protected Point TranslatePosition(Point current, Panel from, Panel to, MouseEventArgs e)
{
Point rtn = new Point(-1, -1);
// get point relative to existing parent
Point fromPoint = e.GetPosition(from);
// get point relative to new parent
Point toPoint = e.GetPosition(to);
// calculate delta
double deltaX = fromPoint.X - toPoint.X;
double deltaY = fromPoint.Y - toPoint.Y;
// calculate new position
rtn = new Point(current.X - deltaX, current.Y - deltaY);
return rtn;
}
Notice that it relies on the MouseEventArgs.GetPosition function to get the position relative to existing and new parent. In cases where there is no MouseEventArgs available, we were creating a new instance and passing it in. This was a hack but seemed to work. Now, in RC0, the MouseEventArgs constructor is internal so this hack no longer works.
Any ideas on how to write a method to do the translation of a point in RC0 that doesn't rely on MouseEventArgs.GetPosition?