tags:

views:

28

answers:

1

I've been messing around with the transforms option in WPF. How can I "add" a new transform to the existing one? I need to perform several different scalings from several different points at unknowable different times and simply add them on to the existing object, rather than re-creating a new transform with just the new scale in it. I've been trying, for example, RenderTransform.Value.ScaleAt(stuff), but nothing seems to happen. I'm in C#.

Thanks.

+1  A: 

The ScaleAt works on a Matrix struct (i.e. the Transform.Value property) and will not be reflected on the actual Transform. What you could do is get the current Matrix, scale it, then apply the new Matrix as a MatrixTransform on the element. Something like this:

Transform t = myObject.RenderTransform;
Matrix m = t.Value;
m.ScaleAt(1.1, 1.1, 0, 0);

myObject.RenderTransform = new MatrixTransform(m);
karmicpuppet
Thanks - but this solution exhibits a really strange bias towards the right side. If the center point is to the right of the object, the scaling is much faster compared to if it's to the left, almost as if the object's center is offset about thirty pixels to the left.
DeadMG