开发者

Adding new RenderTransforms to WPF Control

开发者 https://www.devze.com 2023-01-15 13:31 出处:网络
I\'ve been messing around with the tra开发者_如何学Pythonnsforms option in WPF. How can I \"add\" a new transform to the existing one? I need to perform several different scalings from several differe

I've been messing around with the tra开发者_如何学Pythonnsforms 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.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号