I've got a canvas where, among other things, I have many groups of points that I created by making two lines in a cross along with a TextBlock with the points name. When the user zooms in on this canvas, I want the user to be able to scale up or down the points in order to view them easier.
The problem I'm having is specifically the scaling of the textblock. I need both the two lines as well as the textblock to scale to the CanvasCenter (center of the crosshairs the respective point). The two lines scale perfectly towards the center when I set the transforms CenterX and CenterY to the the center but the textblock scales way off, towards the bottom right of the canvas.
Am I misunderstanding what exactly centerX and centerY are?
public void ScaleDown()
{
ScaleTransform lineTransform = new ScaleTransform();
ScaleTransform textTransform = new ScaleTransform();
scale *= 0.90;
lineTransform.ScaleX = scale;
lineTransform.ScaleY = scale;
lineTransform.CenterX = CanvasCenter[0];
lineTransform.CenterY = CanvasCenter[1];
textTransform.ScaleX *= scale;
textTransform.ScaleY *= scale;
textTransform.CenterX = CanvasCenter[0];
textTransform.CenterY = CanvasCenter[1];
NameText.RenderTransform = textTransform;
Line1.RenderTransform = lineTransform;
Line2.RenderTransform = lineTransform;
}
I have tried scaling to the center and I expected it to move closer to that center, but it moved in a completely different direction.